CLKSER page# 0001 next
2: COMMENT ⊗   VALID 00091 PAGES
3: C REC  PAGE   DESCRIPTION
4: C00001 00001
5: C00010 00002    APRINT  8 SEPT 67
6: C00013 00003    HERE, WE GENERATE ANY USER CLOCK-INTERRUPTS NEEDED.
7: C00017 00004     HERE WE REQUEST CH7 INTERRUPT AND DISMISS
8: C00020 00005    ADDRESS BREAK SYSTEM.
9: C00023 00006    APRER   OTHER APR INTERRUPTS BESIDES CLOCK
10: C00026 00007     THIS ROUTINE REQUESTS USER INTERRUPT FOR VARIOUS APR-TYPE TRAP CONDITIONS
11: C00030 00008    HERE WE'VE DECIDED THAT THIS LOSER DOESN'T HAVE A VALID TRAP ADDRESS.
12: C00032 00009     HERE WE HAVE A NON-TRIVIAL ERROR
13: C00034 00010     WE GET HERE ON AN ERROR IN THE EXEC
14: C00036 00011    SYSTEM CLOBBERED     DETECTED BY SYS WR REF KLUDGE
15: C00038 00012    CLOCK   24 JULY 67
16: C00040 00013    HERE AT CLK INTERRUPT LEVEL  -  CLKINT
17: C00042 00014    P2 CLK INTS COME HERE
18: C00043 00015     HERE IT IS NOT TIME TO TAKE A REAL CLOCK INTERRUPT
19: C00046 00016    SET TIME FLAGS, UPDATE SYSTEM TIME, COUNT DOWN PROCESSOR ALIVE FLAGS
20: C00052 00017     KEEP INFORMATION FLOWING BETWEEN THE PROCESSORS
21: C00055 00018     HERE IS THE GUY THAT CALLS UP PHANTOM PROCESSES LIKE BATCH MONITORS
22: C00059 00019     MAINTAIN P1'S 2-PROCESSOR COMMUNICATION
23: C00062 00020     HERE IS SUBROUTINE FOR PHANTOM ROUTINES
24: C00065 00021     MORE PHANTOM CLOCK LEVEL ROUTINES, WAITING FOR RESOURCES
25: C00067 00022     HERE WE FLUSH THE DISASTER TYPEOUT BUFFER THEN PROCESS CLOCK REQUESTS
26: C00069 00023     IF WE ARE SHUFFLING 1K AT A TIME, DO ANOTHER K HERE, THEN CALL SCHEDULER
27: C00072 00024    DIFFERENT JOB, SAVE SOFTWARE STATE(HARDWARE ALREADY SAVED)
28: C00075 00025    S2U AND U2S
29: C00078 00026    RESTORE HARDWARE STATE OF CURRENT JOB
30: C00080 00027    THE NULL JOB
31: C00082 00028     CHECKSUM ROUTINE. CALL WITH IOWD IN TAC, RETURNS CHECKSUM IN TAC1.
32: C00083 00029    BEGIN   SYSFIX  VERIFY SYSTEM CHECKSUM AND FIX IT IF WRONG.
33: C00090 00030     THIS IS WHERE THE USER INTERRUPT HANDLER RESIDES . . .
34: C00096 00031     ROUTINE TO GET FIRST SERVICABLE INTERRUPT BIT FROM WORD OF BITS
35: C00098 00032     HERE WE CLEAR THE INTERRUPT BIT IN JBTIRQ AND ACTUALLY
36: C00103 00033     HERE WE INITIALIZE ALL THE SYSTEM VARIABLES IN PREPARATION FOR RUNNING THE USER INTERRUPT PROCESS
37: C00107 00034     HERE, HE IS NOT CONTINUING AFTER A UWAIT, BUT IS BEING RUN REGULARLY
38: C00110 00035     ROUTINE TO TYPE OUT ERROR MESSAGE FOR ILL. STARTING ADDRESS
39: C00112 00036     ROUTINE TO SWAP A GUY IN SO HE MAY BE INTERRUPTED
40: C00115 00037     WE COME BACK TO HERE AFTER AN INTERRUPT - INTCH7,INTDSM,INTOUT,INTERR
41: C00119 00038     WE GET HERE FROM A DEBREAK UUO - INTDEB, INTERP, INTAPR
42: C00122 00039    INTKILL  ROUTINE TO CLEAR A JOB'S INTERRUPT ENABLINGS AND RESET HIS MASKS
43: C00124 00040    INIJOB          ROUTINE TO INITIALIZE A JOB SLOT
44: C00129 00041    COMCON  4 AUG 67         THE COMMAND DECODER
45: C00132 00042    COMMAND
46: C00135 00043    COMFND: MOVE    UUO,COMTAB(AC1) SAVE FULL COMMAND NAME
47: C00138 00044    CHKACT:
48: C00141 00045    RETURN FROM COMMAND SETUP ROUTINE
49: C00144 00046    PCRLF:  TLNE AC2,ERRFLG         DID AN ERROR OCCUR?
50: C00147 00047    TABLE OF CONSOLE COMMANDS
51: C00150 00048    DEFINE NAMES
52: C00155 00049     MORE COMMANDS . . .
53: C00159 00050    BEGIN COMTBL                    GENERATE TABLE OF SIXBIT COMMAND NAMES
54: C00161 00051    CALLED FROM COMMAND DECODER WHICH IS CALLED FROM CLOCK ROUTINE
55: C00164 00052    COR0:           CALLED FROM CORE COMMAND TO ZERO CORE
56: C00166 00053    PTTY PJOB KJOB
57: C00172 00054    IFN FTLOGIN,<                    PRINT OUT A JOB'S PROJECT PROGRAMMER NUMBER
58: C00176 00055     SERVICE LEVEL COMMAND
59: C00187 00056    KILL N ---- KILL JOB N IMMEDIATELY! -- OR MAYBE LATER
60: C00191 00057    PRIVILEGED KILL ROUTINE, FLUSHES THINGS WITHOUT WAITING
61: C00192 00058    KJOB2:  JUMPE   PROG,JOBKA      DOES JOB HAVE CORE?
62: C00195 00059     "START L" OR "START" - START AT LOC. L OR STARTING ADDRESS
63: C00200 00060    CCONTINUE, CONTINUE, DDT
64: C00203 00061    SETUWP, CLRUWP, ENABLE, DISABLE
65: C00208 00062     "CORE  #" - ASSIGNS #*1024 WORDS OF CORE TO JOB
66: C00211 00063    COR4:   MOVSI   TAC,NOINCK      DON'T INITIALIZE A JOB
67: C00214 00064    PRJOB:  PUSHJ P,INLMES
68: C00217 00065    "HELP" -HELP COMMAND
69: C00219 00066    ALOGIN, SETTPV, CLRTPV
70: C00221 00067    "LOGIN" - LOGIN COMMAND
71: C00225 00068    R, RUN, SAVE, SSAVE, GET COMMANDS
72: C00230 00069     "ASSIGN DEV:NAME" - ASSIGN DEVICE TO JOB AND GIVE IT LOGICAL NAME
73: C00242 00070    ALREADY ASSIGNED TO ANOTHER JOB
74: C00245 00071    "DEASSIGN DEV" - DEASSIGNS DEVICE FROM CONSOLE
75: C00248 00072    REASSIGN UUO
76: C00250 00073    ROUTINE COMMON TO REASSIGN UUO AND COMMAND
77: C00252 00074    REASS4: HRRZ DSER,DEVSER(DEVDAT)
78: C00254 00075    REASE1: POP PDP,TAC
79: C00255 00076    "ATTACH DEVNAM" -ATTACHES A PREVIOUSLY PARTITIONED DEVICE
80: C00258 00077    IFN FTLOGIN,<
81: C00261 00078    ATT2:   EXCH    DDB,TAC1                PUT LINE NO. OF OUR TTY IN DDB
82: C00262 00079    FLUSH THIS TTY'S BUFFERS IF NOT IN USE BY A JOB
83: C00264 00080    "FORK", "CFORK", "DETACH" AND "CDETACH" COMMANDS
84: C00271 00081    "DAYTIME" - PRINT TIME OF DAY
85: C00277 00082    "TIME (JOB NO.)" - PRINT TOTAL AND INCREMENTAL RUNNING TIME FOR A JOB
86: C00285 00083    ROUTINE TO LET TTY TALK TO ANY OTHER RING OF TTYS
87: C00286 00084    "EXAMINE LOC" - LOOKS A CONTENTS OF LOC AND PRINTS IN OCTAL
88: C00290 00085    "DEPOSIT LH RH LOC" - DEPOSITS XWD LH,RH IN LOCATION LOC
89: C00293 00086    "BLANK" OR NO ALPHA NUMERIC BEFORE BREAK CHAR COMMAND
90: C00294 00087     "FINISH DEVICE" - CLOSES,RELEASE AND DEASSIGNS DEVICE
91: C00300 00088    "RESOURCES" - PRINT OUT AVAILABLE DEVICES AND FREE BLOCKS ON THE DISK
92: C00304 00089    RUNCHK, DLYCOR, DLYCR1
93: C00307 00090    SEARCH DEVICE CHAIN FOR DSK WITH COUNTS ON
94: C00309 00091    "FILES <filename or job number>" -- print status of open files.
95: C00321 ENDMK
96: C⊗;
    CLKSER page# 0002 next  prev
98: SUBTTL  APRINT  8 SEPT 67
99: 
100: ;THIS SERVICE ROUTINE RUNS ON A HIGH PRIORITY CHANNEL
101: ;AND REQUESTS INTERRUPTS ON LOWER CLK CHANNEL
102: ;FOR SCHEDULING JOBS AND ERROR HANDLING THAT THE USER
103: ;IS NOT ENABLED TO HANDLE HIMSELF
104: 
105: AP2CHL←CAT(P2CH,\APRCHN)
106: CL2CHL←CAT(P2CH,\CLKCHN)
107: 
108: 
109: AP2INT:
110:         EXCH    PID,APRID+P2PID
111:         JRST    BREAKX
112: 
113: APRINT:
114:         EXCH    PID,APRID+P1PID
115: ;APR IS ALWAYS ENABLED FOR CLOCK,ILM,NXM,PDLOV, AND CONS.
116: ;ALSO AROV AND PC CHNG IF THE USER REQUESTS.
117: 
118:         CONSZ   APR,ADRBRK      ;ADDRESS BREAK?
119:         JRST    BREAK           ;YES, GO PROCESS
120: BREAKX: CONSO   APR,1B26        ;YES, IS IT CLOCK?
121:         JRST    APRER           ;NO, GO CHECK ERROR FLAGS
122: 
123: ;CLOCK HAS TICKED.  DO TIME ACCOUNTING
124:         AOS     TIME(PID)       ;YES, INCREMENT TIME OF DAY
125:         AOS     UPTIME(PID)     ;DEC 3.16 INCREMENT UP TIME.
126:         SETOM   TIMEFF(PID)     ;FLAG THAT APR CLOCK HAS TICKED
127:         HLLOS   CLKFLG(PID)     ;SET FLAG FOR CLK FORCED INTERRUPT
128:         MOVEM   TAC,APRTAC(PID) ;GET AN ACCUMULATOR
129:         CONSO   PI,7400         ;ARE WE AT INTERRUPT LEVEL (CH4-7)?
130:         JRST    BREAK3          ;NO
131:         AOS     INTIME(PID)     ;BUMP INTERRUPT TIME
132:         JRST    APRI1           ;YES, SKIP TIME ACCOUNTING
133: 
134: BREAK3: SKIPN   TAC,JOB(PID)    ;INCREMENT RUNNING TIME
135:         JUMPN   PID,APRI1       ;IF P2, DON'T BUMP NULL TIME
136:         AOS     TTIME(TAC)      ;TIME ACCOUNTING (RTIME IS NO LONGER COUNTED)
137:         AOS     JBTRNB(TAC)     ;INCREMENT HIS JOB LOADING TOO.
138:         JUMPE   TAC,APRI1       ;ESCHEW OBFUSCATION
139:         MOVEM   AC1,APRAC1(PID) ;GET AN AC
140:         HLRZ    AC1,JBTADR(TAC) ;GET CURRENT JOB'S PROTECTION
141:         LSH     AC1,-12
142:         ADDI    AC1,1
143:         ADDM    AC1,JBTKCJ(TAC) ;KILO-CORE*JIFFIES
144:         MOVE    AC1,APRAC1(PID) ;GET BACK OUR AC
145: APRI1:  JUMPN   PID,APRADD
146:         SOSGE   DDCNT           ;HAS DATA DISK TIMED OUT??
147:         JRST    DDCLK           ;YES, GO FLUSH IT
148:         SKIPE   DDSTART         ;DO WE NEED TO START IT UP?
149:         JRST    DDSTRT          ;YES, DO SO.
150: 
    CLKSER page# 0003 next  prev
152: ;HERE, WE GENERATE ANY USER CLOCK-INTERRUPTS NEEDED.
153: ; APRLST POINTS TO A LIST, 2-WORDS PER ENTRY
154: ; LH OF FIRST WORD IS TIME BETWEEN INTERRUPTS
155: ; RH OF FIRST WORD IS JOB NUMBER
156: ; SECOND WORD IS NEGATIVE COUNT OF TIME BETWEEN INTERRUPTS
157: 
158: APRADD:
159:         JUMPN   PID,APRI2       ;NO CLOCK INTERRUPTS ON P2
160:         SKIPN   TAC,APRLST      ;ANY INTERRUPTS TO GIVE?
161:         JRST    APRI2           ;NO, EXIT NOW
162:         MOVEM   AC1,APRAC1(PID) ;SAVE SOME AC'S AND PICK UP A PDL
163:         MOVEM   J,APRJ(PID)
164:         MOVEM   AC2,APRAC2(PID)
165:         EXCH    P,APRPDL(PID)
166: APRCI2: SKIPN   J,(TAC)         ;END OF LIST?
167:         JRST    APRCI9          ;YES, RESTORE ACS AND LEAVE
168:         AOSGE   1(TAC)          ;TIME EXPIRED YET?
169:         JRST    APRCI4          ;NO, LOOP AROUND
170:         MOVSI   AC2,INTCLK      ;MAKE SURE HE IS STILL ENABLED
171:         TDNN    AC2,JBTIEN(J)
172:         JRST    APRCI5          ;NOT ENABLED, ALLOWABLE TIMING ERROR, JUST DELETE
173:         HLRZ    AC1,J           ;RESET TIME
174:         MOVNM   AC1,1(TAC)
175:         IORM    AC2,JBTIRQ(J)
176:         SETOM   INTREQ(PID)
177: APRCI4: ADDI    TAC,2           ;LOOP AROUND FOR NEXT ENTRY
178:         JRST    APRCI2
179: 
180: 
181: 
182: ;APRDEL DELETE CLOCK INT ENTRY POINTED TO BY TAC
183: ;DELETES FS BLOCK AND SKIP RETURNS IF LAST ENTRY IS DELETED
184: ;CALL ONLY AFTER DOING CONO PI,APROFF
185: APRDEL:
186:         JUMPN   PID,CPOPJ
187:         MOVEI   AC1,2(TAC)
188: APRCI6: SKIPN   (AC1)
189:         JRST    APRCI7
190:         ADDI    AC1,2           ;FIND END OF LIST AND MOVE LAST ENTRY INTO ENTRY
191:         JRST    APRCI6          ;BEING DELETED
192: 
193: APRCI7: MOVE    AC2,-2(AC1)     ;PICK UP LAST ENTRY
194:         MOVEM   AC2,(TAC)
195:         MOVE    AC2,-1(AC1)
196:         MOVEM   AC2,1(TAC)
197:         SETZM   -2(AC1)
198:         MOVEI   AC1,-2(AC1)
199:         CAME    AC1,APRLST
200:         POPJ    P,
201: APRCI8: AOS     (P)
202: APRDRL: MOVEI   AC1,0
203:         EXCH    AC1,APRLST
204:         JRST    FSGIVE
205: 
206: APRCI5: PUSHJ   P,APRDEL        ;DELETE THE ENTRY, SKIP IF THAT WAS THE LAST ONE
207:         JRST    APRCI2
208:         JRST    APRCI3                  ;LIST EXHAUSTED
209: APRCI9: CAMN    TAC,APRLST              ;IS LIST EMPTY?
210:         PUSHJ   P,APRDRL
211: APRCI3: EXCH    P,APRPDL(PID)           ;RESTORE THE ACS WE SAVED
212:         MOVE    AC1,APRAC1(PID)
213:         MOVE    AC2,APRAC2(PID)
214:         MOVE    J,APRJ(PID)             ;FALL INTO APRI2
    CLKSER page# 0004 next  prev
216: ; HERE WE REQUEST CH7 INTERRUPT AND DISMISS
217: 
218: APRI2:  SKIPE   SPWUUF(PID)     ;SPACEWAR ACTIVE?
219:         SOSE    SPWTMO(PID)     ;YES. DECREMENT SPACEWAR TIMEOUT
220:         JRST    APRI2Z          ;ALL IS OK.
221: 
222: ;THIS IS HOW WE BLOW UP THE SPACEWARRIOR.
223:         MOVEI   TAC,46          ;ASSUME PI CHANNEL 3 INTERRUPTED CH 7
224:         CONSZ   PI,1000         ;CH6 IN PROGRESS?
225:         JRST    APRI2A          ;YES
226:         CONSZ   PI,2000         ;CH5 IN PROGRESS?
227:         JRST    APRI2B          ;YES
228:         CONSO   PI,4000         ;CH4 IN PROGRESS?
229:         JRST    APRI2D          ;NO. IT WAS CH3
230:         JRST    APRI2C
231: APRI2A: ADDI    TAC,2           ;CHANNEL 6
232: APRI2B: ADDI    TAC,2           ;CHANNEL 5
233: APRI2C: ADDI    TAC,2           ;CHANNEL 4
234: APRI2D: JUMPN   PID,.+2
235:         IORI    TAC,100                 ;MAOFF
236:         MOVEM   TAC1,SPWBLO(PID)        ;SAVE TAC1 A WHILE
237:         MOVE    TAC1,[JRST SPTMOE]
238:         MOVEM   TAC1,SPWXCT(PID)        ;MAKE SURE WE CATCH UUOCON EXITING
239:         EXCH    TAC1,@(TAC)             ;WHEE!
240:         TLNE    TAC1,USRMOD             ;USER MODE?
241:         JRST    APRI2Y                  ;YES. THIS IS EASY
242:         EXCH    TAC1,@(TAC)             ;PUT BACK THE INTERRUPTED PC
243:         MOVE    TAC1,UUO0(PID)          ;GET UUO0
244: APRI2Y: EXCH    TAC1,SPWBLO(PID)        ;STORE INTERRUPTED ADDRESS.
245: 
246: APRI2Z: MOVE    TAC,APRTAC(PID)         ;RESTORE TAC
247:         CONO    PI,1B24+1(7-CLKCHN)    ;REQUEST INTERRUPT ON CLOCK CHANNEL.
248:         SETOM   DSFLAG(PID)             ;TELL DPYSER CLOCK HAS TICKED.
249:         CONSZ   APR,@APRIN1(PID)        ;IS THE USER ENABLED FOR ANY FLAGS?
250:                                         ;(APRIN1 SET EACH TIME A USER RUNS)
251:         JRST    APRER                   ;YES, GO PROCESS TRAP.
252:         CONO    APR,1B26+APRCHN         ;NO, CLEAR THE CLOCK FLAG
253: PBRET:  JUMPN   PID,P2RET
254: P1RET:  EXCH    PID,APRID+P1PID
255:         JEN     @APRCHL                 ;DISMISS INTERRUPT
256: 
257: P2RET:  EXCH    PID,APRID+P2PID
258:         JEN     @AP2CHL
259: 
    CLKSER page# 0005 next  prev
261: ;ADDRESS BREAK SYSTEM.
262: ;PUT THE EXCEPTED PCS (THE ONES YOU WANT TO IGNORE BREAKS FROM) IN BRKTAB,
263: ; AND THE NUMBER OF EXCEPTED PCS IN BRKNUM.
264: ;WHEN A BREAK OCCURS FROM SOME UNEXCEPTED PC, IT EXECUTES THE CODE AT
265: ;BRKHIT, WHICH MAY BE PATCHED TO WHATEVER YOU WANT.
266: ;NOTE THAT IF BRKNUM≤0 ALL BREAKS ARE EXCEPTED AND AN ERROR MESSAGE RESULTS
267: 
268: BREAK:  MOVEM   TAC,BRKTAC      ;SAVE A COUPLE OF ACCUMULATORS
269:         MOVEM   AC1,BRKAC1
270:         HRRZ    TAC,APRCHL      ;PICK UP BREAK PC+1
271:         SUBI    TAC,1           ;MAKE IT HONEST
272:         SKIPLE  AC1,BRKNUM      ;ARE WE READY FOR A BREAK?
273:         CAILE   AC1,BRKMAX      ;YES.  REASONABLE NUMBER OF EXCEPTED PCS?
274:         JRST    BRKERR          ;NO. NOT READY
275:         CAME    TAC,BRKTAB-1(AC1)       ;IS THIS PC EXCEPTED?
276:         SOJG    AC1,.-1                 ;NO. TRY NEXT ONE
277:         JUMPGE  AC1,BRKXIT              ;JUMP IF WE MATCHED SOME EXCEPTED PC.
278: BRKHIT:
279: REPEAT 10,<JFCL>
280: BRKXIT:
281:         MOVE    TAC,BRKTAC              ;RESTORE ACCUMULATORS
282:         MOVE    AC1,BRKAC1
283:         CONO    APR,ADRBRK              ;CLEAR BREAK BIT
284:         JRST    BREAKX                  ;RETURN TO CH3 CODE
285: 
286: BRKERR: EXCH    P,APRPDL(PID)
287:         PUSHACS
288:         CAIG    AC1,BRKMAX              ;SKIP IF ILLEGAL VALUE OF BRKNUM
289:         JUMPGE  AC1,BRKER1              ;JUMPE IF LEGAL VALUE OF BRKNUM
290:         PUSHJ   P,DISMES
291:         ASCIZ   /ILLEGAL VALUE OF BRKNUM = /
292:         HRRZ    TAC,BRKNUM
293:         PUSHJ   P,DISLOC
294:         PUSHJ   P,DISCRLF
295:         SETZM   BRKNUM
296: BRKER1: PUSHJ   P,DISMES
297:         ASCIZ   /ADDRESS BREAK, PC=/
298:         MOVE    TAC,APRCHL
299:         PUSHJ   P,DISLOC
300:         PUSHJ   P,DISCRLF
301:         POPACS
302:         EXCH    P,APRPDL(PID)
303:         JRST    BRKXIT
    CLKSER page# 0006 next  prev
305: ;APRER  OTHER APR INTERRUPTS BESIDES CLOCK
306: 
307: APRER:                          ;HERE TOO IF USER MIGHT BE ENABLED FOR CLKINTS
308:         EXCH    TAC,@APRCH(PID)         ;SAVE TAC, GET PC WORD
309:         CONSZ   APR,ILM
310:         JRST    APRMPV                  ;CLEAN UP AFTER CPU ON MPV
311:         TLNN    TAC,USRMOD              ;IS IT IN USER MODE?
312:         JRST    APRER2                  ;NO, PRINT MESSAGE AND STOP JOB
313: APRER1: CONSO   PI,7000                 ;SPACEWAR LOSSAGE?
314:         SKIPN   SPWUUF(PID)             ;IN CH7. SPACEWAR ACTIVE?
315:         JRST    APRER6                  ;NOT SPACEWAR
316:         EXCH    TAC,@APRCH(PID)
317:         JUMPE   PID,APRSWP
318:         EXCH    PID,APRID+P2PID
319:         JRST    SP2INT
320: 
321: APRSWP: EXCH    PID,APRID+P1PID
322:         JRST    SPWINT
323: 
324: APRER6: SKIPN   INTACT(PID)             ;KILL IF ALREADY AT INT. LEVEL
325:         CONSO   APR,@APRIN1(PID)        ;IS USER ENABLED FOR THIS INTERRUPT?
326:         JRST    APRER2                  ;NO, STOP JOB AND PRINT MESSAGE
327:         EXCH    JDAT,JOBDAT(PID)        ;SAVE JDAT, GET CURRENT JOB DATA AREA ADR.
328: 
329: ;WHEN THE KA-10 IS FIXED, DELETE ALL OF THIS DOWN TO APRE6A (BUT NOT CONSO)
330: ;ALSO PUT HRRI INTO APRMPV
331:         CONSZ   APR,ILM                 ;ILL MEM REF?
332:         TLNE    TAC,20000               ;YES. SKIP IF NOT ILDB/IDPB
333:         JRST    APRE6A                  ;NOT ILM OR ILM AND BIS FLAG IS SET
334:         HRRI    TAC,-1(TAC)             ;ASSUME HE WAS DOING A WRITE OF SOME KIND
335: 
336: APRE6A: CONSO   APR,@APRIN2(PID)        ;ENABLED VIA NEW USER INTERRUPT SYSTEM?
337:         JRST    APRER7                  ;NO. OLD STYLE.
338: 
    CLKSER page# 0007 next  prev
340: ; THIS ROUTINE REQUESTS USER INTERRUPT FOR VARIOUS APR-TYPE TRAP CONDITIONS
341: 
342:         MOVEM TAC,APRIN3(PID)   ; SAVE PC FOR CLKINT
343:         EXCH J,JOB(PID)
344:         CONI APR,TAC
345:         AND TAC,APRIN2(PID)
346:         EXCH P,APRPDL(PID)
347:         IORM TAC,JBTIRQ(J)
348:         EXCH P,APRPDL(PID)
349:         SETOM INTREQ(PID)       ; NOW REQUEST AN INTERRUPT
350:         EXCH J,JOB(PID)
351: ;       CONSZ APR,ILM
352: ;       AOS APRIN3(PID)         ;LET'S LEAVE IT ALONE - FW
353:         MOVE TAC,[JRST JOBTM5]
354:         MOVEM TAC,JOBTM5(JDAT)
355:         MOVE TAC,[XWD USRMOD,JOBTM5]
356:         EXCH JDAT,JOBDAT(PID)
357:         HLLOS CLKFLG(PID)
358:         CONO PI,1B24+1(7-CLKCHN)
359:         JRST APRER3
360: 
361: ;ENABLED VIA OLD-STYLE INTERRUPTS.
362: APRER7: MOVEM   TAC,JOBTPC(JDAT)        ;STORE LOSER PC IN JOB DATA AREA
363:         HRRZ    TAC,JOBAPR(JDAT)        ;GET TRAP ROUTINE ADDRESS
364:         CAIGE   TAC,JOBPFI              ;LEGAL TRAP ADDRESS? (NO TRAPS TO ACS)
365:         JRST    APRER5                  ;NO.
366:         MOVEM   TAC,APRTAC(PID)         ;
367:         HRRZ    TAC,JOBTPC(JDAT)        ;DID FIRST INSTRUCTION OF TRAP ROUTINE
368:         CAMN    TAC,APRTAC(PID)         ;GENERATE A BAD ADDRESS?
369:         JRST    APRER5                  ;YES IT WAS, TRAP IT
370:         ADDI    TAC,1
371:         CAMN    TAC,APRTAC(PID)         ;REMEMBER THAT WE BUGGERED ADDRESS
372:         JRST    APRER5
373:         CONI    APR,JOBCNI(JDAT)        ;STORE APR IN JOB DATA AREA
374:         HLL     TAC,JOBTPC(JDAT)        ;NOW PUT THE ENTIRE PC TOGETHER AGAIN
375:         TLO     TAC,USRMOD              ;MPV COMES FROM EXEC MODE TOO,
376:                                         ;MAKE SURE WE GET TO USER MODE
377:         HRR     TAC,JOBAPR(JDAT)
378:         EXCH    JDAT,JOBDAT(PID)        ;RESTORE JDAT,JOBDAT
379: APRER3: TLZ     TAC,440000              ;CLEAR PC CHANGE AND AR OVF FLAGS
380:                                         ;SO INTERRUPT MAY BE DISMISSED
381:         EXCH    TAC,@APRCH(PID)         ;RESTORE TAC & @APRCH(PID)
382:         CONO    APR,530110+APRCHN       ;CLEAR ERROR FLAGS WHICH CAN CAUSE
383:                                         ;INTERRUPT (EXCEPT CLOCK).
384:         JUMPN   PID,P2RET
385:         JRST    P1RET
386: 
387: APRMPV:                                 ;CLEANUP AFTER CPU ON ILM
388: ;       HRRI    TAC,-1(TAC)             ;BACK UP PC TO POINT AT LOSER
389:         CONO    APR,400000!APRCHN       ;DON'T MENTION PDLOV YET IF BOMBED ON MPV
390:         TLNE    TAC,USRMOD              ;MAY HAVE TO WORRY IF EXEC LOST
391:         JRST    APRER1                  ;NO, JUST LOSER
392:         CONSO   PI,67400                ;PI IN PROGRESS?
393:         JRST    APRMP1                  ;NO. MPV FROM UUO LEVEL: GO TO UADERR
394:         CONSZ   PI,00400                ;IN PROGRESS ON CH7?
395:         SKIPN   SPWUUF(PID)             ;IN CH7. AT SPACEWAR LEVEL?
396:         JRST    APRER6                  ;NOT SPACEWAR.  MPV FROM EXEC. (HOW??)
397: APRMP1: HRRI    TAC,UADERR              ;SEND HIM TO ADDRESS CHECK
398:         JRST    APRER3
    CLKSER page# 0008 next  prev
400: ;HERE WE'VE DECIDED THAT THIS LOSER DOESN'T HAVE A VALID TRAP ADDRESS.
401: ;SO WE CLEAR APRIN1(PID) TO PREVENT FURTHER DISTRACTION.
402: APRER5: MOVE    TAC,JOBTPC(JDAT)        ;RESTORE PC AND FLAGS
403:         EXCH    JDAT,JOBDAT(PID)        ;RESTORE JOB DATA AREA ADDRESS
404:         SETZM   APRIN1(PID)
405: APRER2: CONSO   APR,MAOFF
406:         CONSO   APR,200         ;DID 6 GET ENABLED FOR PC CHANGE INTERUPT?
407:         JRST    APRERA          ;NO
408:         CONO    APR,500!APRCHN          ;CLEAR IT.
409:         EXCH    P,APRPDL+P2PID
410:         PUSHACS
411:         PUSH    P,TAC
412:         PUSHJ   P,DISMES
413:         ASCIZ/UNEXPECTED PC CHANGE TRAP. PC=/
414:         POP     P,TAC
415:         PUSHJ   P,DISOCT
416:         PUSHJ   P,DISCRLF
417:         POPACS
418:         HLLZS   APRIN1+P2PID    ;MAKE SURE IT DOESN'T HAPPEN AGAIN
419:         EXCH    P,APRPDL+P2PID
420: APRERA: CONSZ   APR,630000      ;DOES EXEC CARE?        ;JS  CONS,PDLOV,NXM,MPV
421:         JRST    APRERB          ;YES!
422:         CONSO   APR,1B26
423:         JRST    APRER9
424:         MOVEM   TAC,APRTAC(PID)
425:         MOVE    TAC,APRIN1(PID)
426:         TRNE    TAC,1B26
427:         CONO    APR,1B26+APRCHN
428:         MOVE    TAC,APRTAC(PID)
429: APRER9: CONSO   APR,110                 ;ARITHMETIC OVERFLOW?
430:         JRST    APRER3
431:         MOVEM   TAC,APRTAC(PID)
432:         MOVE    TAC,APRIN1(PID)
433:         TRNN    TAC,10                  ;USER ENABLED FOR AROV?
434:         CONO    APR,40!APRCHN
435:         TRNN    TAC,100                 ;OR FOV (PC CHANGE ON 6)
436:         CONO    APR,400!APRCHN
437:         MOVE    TAC,APRTAC(PID)
438:         JRST    APRER3
    CLKSER page# 0009 next  prev
440: ; HERE WE HAVE A NON-TRIVIAL ERROR
441: 
442: APRERB: MOVEM   TAC,APRPC(PID)  ;STORE ERROR PC FOR CLK CHANNEL
443:         CONI    APR,APRERR(PID) ;STORE ERROR FLAGS
444:                                 ;(ALSO USED AS ERROR FLAG)
445:         HLLOS   CLKFLG(PID)     ;SET FLAG FOR CLK INTERRUPT
446:         SETOM   SCHEDF(PID)     ;FLAG THAT RESCHEDULING IS NEEDED
447:                                 ;(EVEN THOUGH PC MAY BE IN EXEC MODE)
448:         CONO    PI,1B24+1(7-CLKCHN)    ;REQUEST INTERRUPT ON CLOCK CHANNEL.
449:         CONSO   APR,ILM         ;ILL MEM REF?
450:         JRST    APRERC
451:         MOVEM   TAC,USAVPC(PID) ;SAVE ERROR PC FOR CLKINT
452:         HRRI    TAC,0           ;YES. FORCE LEGAL ADDRESS SO
453:         JRST    APRER4          ;PDP-10 WILL NOT HANG (CROCK!) ON WILD PC.
454: APRERC: TLNN    TAC,USRMOD      ;PC IN USER MODE?
455:         CONSO   PI,177B27(1B27(7-APRCHN))     ;ARE WE SOME OTHER PI CHANEL?
456:         CAIA                    ;NO.
457:         JRST    APRMES          ;SYSTEM SCREW-UP!!
458: APRER4:CONSO   APR,NXM         ;NON-EXISTANT MEMORY?
459:         JRST    APRER3          ;NO. RESTORE ACS AND DISMISS
460:         MOVEI   TAC,(TAC)       ;YES. IS IT PC?
461:         CAML    TAC,RMEMSIZ     
462:         MOVEI   TAC,[CONO PI,1B24!1(7-CLKCHN)]
463:                                 ;YES. DISMISS TO CLKINT
464:         HLL     TAC,APRPC(PID)
465:         JRST    APRER3          ;RESTORE ACS AND DISMISS
    CLKSER page# 0010 next  prev
467: ; WE GET HERE ON AN ERROR IN THE EXEC
468: 
469: APRMES: EXCH    P,APRPDL(PID)
470:         PUSHACS
471:         PUSH    P,TAC
472:         PUSHJ   P,DISDATE
473:         PUSHJ   P,DISMES
474:         ASCIZ   /CH3 ERROR IN EXEC.  PC = /
475:         POP     P,TAC
476:         PUSHJ   P,DISOCT
477:         PUSHJ   P,DISMES
478:         ASCIZ   /
479: APR CONI = /
480:         MOVE    TAC,APRERR(PID)
481:         PUSHJ   P,DISOCT
482:         PUSHJ   P,DISCRLF
483:         PUSHJ   P,SYSFIX
484:         JFCL                    ;NOT IN MONITOR
485:         CAIA                    ;ERROR, BUT COULDN'T FIX
486:         JRST    MONOK           ;FOUND ERROR AND FIXED(I HOPE!)
487:         PUSHJ   P,ALTNOW
488:         JFCL
489:         PUSHJ   P,DISFLU        ;FLUSH MESSAGES TO CTY
490:         PUSHJ   P,DDTCALL       ;THIS DOES REQUIRE INTERVENTION
491:         JRST    MONOK1
492: MONOK:  DEBCHECK
493: MONOK1: SKIPE   DISFLAG
494:         JRST    APREM1
495:         POPACS
496:         EXCH    P,APRPDL(PID)
497:         JRST    APRER4
498: 
499: APREM1: PUSHJ   P,DISMES
500:         ASCIZ   /RELOAD OR FIND A WIZARD.
501: /
502:         PUSHJ   P,DISFLUSH
503:         POPACS
504:         HALT    AUTOLOAD
    CLKSER page# 0011 next  prev
506: ;SYSTEM CLOBBERED     DETECTED BY SYS WR REF KLUDGE
507: REPEAT 0,<
508: CLBFIX: CONO    APR,CLRCLB+APRCHN       ;CLEAR IT SO WE DON'T GET BACK HERE AGAIN
509:         EXCH    P,APRPDL(PID)
510:         PUSHACS                 ;GET SOME ACS
511:         PUSHJ P,DISDATE
512:         PUSHJ P,DISERR
513:         [ASCIZ/π⊗⊗ππSYSTEM CLOBBERED
514: PC+1 = /]
515:         DISARG OCT,<@APRCH(PID)>
516:         [ASCIZ/    /]
517:         -1
518:         MOVE TAC,@APRCH(PID)
519:         TLNE TAC,USRMOD         ;WAS IT A LOSER?
520:         JRST USRCLB             ;YES
521:         PUSHJ P,DISMES
522:         ASCIZ/PI = /
523:         CONI PI,TAC
524:         PUSHJ P,DISLOC
525:         PUSHJ P,DISERR
526:         [ASCIZ/
527: C(P) = /]
528:         DISARG OCT,<APRPDL(PID)>
529:         [ASCIZ/
530: /]
531:         -1
532: CLBFX1: PUSHJ   P,SYSFIX
533:         JFCL
534:         JFCL
535:         SKIPN   DEBMODE         ;DO WE WANT TO STOP
536:         JRST    CLBRET
537:         SETOM   DISFLAG
538:         PUSHJ   P,DISFLUSH
539:         POPACS                  ;LET DDT LOOK AT THE REAL ACS
540:         PUSHJ   P,DDTCAL
541:         JRST    CLBRT1
542: CLBRET: POPACS
543: CLBRT1: EXCH    P,APRPDL(PID)
544:         JRST    PBRET
545: 
546: USRCLB: MOVE    J,JOB(PID)
547:         PUSHJ   P,DISJOB
548:         CONI    PI,TAC
549:         TRNN    TAC,400         ;SPACEWAR?
550:         JRST    USRCL1
551:         PUSHJ   P,DISMES
552:         ASCIZ   /  SPCWAR/
553: USRCL1: PUSHJ   P,DISCRLF
554:         JRST    CLBFX1          ;NOW TRY TO FIX IT!
555: >
    CLKSER page# 0012 next  prev
557: SUBTTL  CLOCK   24 JULY 67
558: 
559: ;THIS ROUTINE RUNS ON THE LOWEST PRIORITY PI CHANNEL AND AT UUO LEVEL
560: ;TO CAUSE AN INTERRUPT ON CLK CHANNEL:
561: ;       SETOM CLKFLG    ;FLAG THAT INTERRUPT HAS BEEN REQUESTED
562: ;       CONO PI,CLKREQ  ;REQUEST PI INTERUPT ON LOWEST PI CHANNEL
563: ;THE FOLLOWING OTHER FLAGS MUST ALSO BE SET
564: ;APRERR-APR DETECTED ERROR IN CURRENT JOB
565: ;SCHEDF-RESCHEDULING MUST TAKE PLACE(EVEN THOUGH PC IN EXEC MODE)
566: ;TIMEF-APR CLOCK HAS TICKED ON HIGH PRIORITY CHANNEL
567: ;SEE APRSER AND RUNCSS TO SEE HOW THIS ROUTINE IS CALLED
568: 
569: ;CLK SERVICE PERFORMS THE FOLLOWING ON A REGULAR BASIS:
570: ;PROCESSES CLOCK QUEUE REQUESTS
571: ;CALLS CONSOLE MONITOR COMMAND DECODER
572: ;CALLS CORE SHUFFLER
573: ;THEN CALLS SCHEDULER
574: ;IF THE CURRENT JOB IS IN EXEC MODE THE ABOVE 4 TASKS ARE
575: ;DELAYED UNTIL THE CURRENT JOB ENTERS A STOPPABLE STATE: I.E., UNTIL
576: ;       1. JOB STARTS TO WAIT FOR A BUSY SHARABLE DEVICE
577: ;       2. JOB STARTS TO WAIT FOR IO TO COMPLETE
578: ;       3. CONTROL ABOUT TO RETURN TO USER MODE
579: ;THEN CLK SERVICE IS ENTERED AT THE UUO LEVEL
580: 
    CLKSER page# 0013 next  prev
582: ;HERE AT CLK INTERRUPT LEVEL  -  CLKINT
583: 
584: CLKIN0:EXCH 17,UUO0+P1PID      ;GET HERE WHEN CLKFLG < 0
585:         MOVEM 17,CLKCHL         ;SIMULATE INT FROM LOSER
586:         EXCH 17,UUO0+P1PID
587: CLKINT:SETZM CLKFLG+P1PID
588:         MOVEM 17,CLKS17+P1PID   ;SAVE AC 17
589:         IFN FTHG, <     MOVEI 17,7
590:                         MOVEM 17,HGCODE >
591:         MOVEI 17,P1PID
592:         SKIPLE INTDISP(17)      ; DO WE HAVE SOMEONE TRYING TO SNEAK INTO CH7
593:         JRST @INTDISP(17)       ; YES, GO SERVICE HIM
594: IFN FTHG,<      SETZM HGCODE    >
595:         SKIPN 17,USAVPC
596:         MOVE 17,CLKCHL          ;IS CURRENT JOB IN USER MODE?
597:         TLNN 17,USRMOD
598:         SKIPE SCHEDF+P1PID      ;NO, IS THIS A FORCED RESCHEDULING INTERRUPT?
599:         JRST CLKIN1
600:         MOVEI 17,P1PID
601:         SKIPE INTREQ(17)
602:         JRST INTNOW
603: CLKINX: MOVE 17,[CONO PI,PIOFF]
604:         MOVEM 17,UUOXIT+P1PID   ;DIVERT TO CLKIN0 ON WAY BACK TO LOSER
605:         MOVE 17,CLKS17+P1PID    ;LEAVE TIMEF SET AND DISMISS INT.
606:         JEN @CLKCHL
607: 
608: CLKIN1: DATAO PI,[0]            ;WE ARE NOW OFFICIALLY IN CHANNEL 7
609:         MOVEM 17,USRPC+P1PID
610:         SETZM USAVPC+P1PID
611:         MOVEI 17,P1PID
612:         JRST CLKERR
    CLKSER page# 0014 next  prev
614: ;P2 CLK INTS COME HERE
615: 
616: CL2IN0:EXCH 17,UUO0+P2PID
617:         MOVEM 17,CL2CHL
618:         EXCH 17,UUO0+P2PID
619: CL2INT:SETZM CLKFLG+P2PID
620:         MOVEM 17,CLKS17+P2PID
621:         MOVE 17,[P2PID]
622:         SKIPLE INTDISP(17)
623:         JRST @INTDISP(17)
624:         SKIPN 17,USAVPC+P2PID
625:         MOVE 17,CL2CHL
626:         TLNN 17,USRMOD
627:         SKIPE SCHEDF+P2PID
628:         JRST CL2IN1
629:         MOVE 17,[P2PID]
630:         SKIPE INTREQ(17)
631:         JRST INTNOW
632: CL2INX: MOVE 17,[CONO PI,PIOFF]
633:         MOVEM 17,UUOXIT+P2PID
634:         MOVE 17,CLKS17+P2PID
635:         JEN @CL2CHL
636: 
637: CL2IN1: MOVEM 17,USRPC+P2PID
638:         SETZM USAVPC+P2PID
639:         MOVE 17,[P2PID]
640:         JRST CLKERR
    CLKSER page# 0015 next  prev
642: ; HERE IT IS NOT TIME TO TAKE A REAL CLOCK INTERRUPT
643: ; HOWEVER WE WILL GIVE A USER INTERRUPT NOW
644: 
645: INTNOW: REPEAT 0,<      ;LET'S SEE IF ANYBODY REALLY NEEDS THIS SHIT
646: 
647: INTNOW: MOVEM 16,INTSAC+16(17)  ; SAVE ACS IN SPECIAL PLACE,
648:                                 ;   BECAUSE JOB MIGHT BE IN TRANSIT
649:         HRRZ 16,@CLKCH(17)
650:         CAIL 16,USRXT0
651:         CAIL 16,USRXT5
652:         SKIPE INTHLD(17)
653:         JRST INTNW2             ;IN USRXIT CODE - COME BACK LATER
654:         MOVEI 16,INTSAC(17)
655:         BLT 16,INTSAC+15(17)
656:         MOVE PID,17
657:         MOVE TAC,CLKS17(PID)
658:         MOVEM TAC,INTSAC+17(PID)
659:         SKIPN TAC,USAVPC(PID)
660:         MOVE TAC,@CLKCH(PID)    ; SAVE PC
661:         SETZM USAVPC(PID)
662:         MOVEM TAC,USRPC(PID)
663:         HRLI P,-CLKPLN          ;LENGTH OF PDL
664:         HRRI P,CLKPDL-1(PID)
665:         SETOM INTNF(PID)
666:         PUSHJ P,INTRUN
667:         SETZM INTNF(PID)
668:         HRLZI 17,INTSAC(PID)
669:         JUMPE PID,CLKBLT
670:         BLT 17,17
671:         JEN @USRPC+P2PID
672: CLKBLT: BLT 17,17
673:         JEN @USRPC+P1PID
674: 
675: INTNW2: MOVE 16,INTSAC+16(17)
676: >
677:         JUMPE 17,CLKINX         ;CLOBBER UUOXIT & DISMISS
678:         JRST CL2INX
679:                                 ;STORAGE FOR CURRENT JOB
680: CLKERR: JSR @CLKSV(17)          ; SAVE ACCUMULATORS
681:         HRLI P,-CLKPLN
682:         HRRI P,CLKPDL-1(PID)
683:         MOVE TAC,UUOXI(PID)
684:         MOVEM TAC,UUOXIT(PID)   ;RESTORE EXIT, NOW THAT WE MADE IT
685: CIP9:
686:         SKIPE TAC,APRERR(PID)   ;IT THIS AN ERROR INTERRUPT?
687:         PUSHJ PDP,APRILM        ;YES, GO PROCESS ERROR 
688:         SKIPE INTREQ(PID)               ; ANY INTERRUPTS PENDING?
689:         PUSHJ P,INTRUN
690:         JUMPN PID,RSCHED
691:         SKIPE SPWGO
692:         PUSHJ P,SPWCHK
693:         SKIPE SP2GO
694:         PUSHJ P,SP2CHK
695:         JRST RSCHED
696: 
697: SPWCHK: SKIPA   TAC1,[,SPWGO(J)]
698: SP2CHK: MOVE    TAC1,[,SP2GO(J)]
699:         SETZ    J,
700:         MOVSI   TAC,SPWERB      ;LOOK FOR ANY SPACEWAR MODE ERRORS
701:         LDB     J,[POINT 6,@TAC1,5]
702:         TDNN    TAC,JBTST2(J)
703:         JUMPN   J,.-2
704:         JUMPE   J,CPOPJ
705:         JRST    SPWMES
    CLKSER page# 0016 next  prev
707: ;SET TIME FLAGS, UPDATE SYSTEM TIME, COUNT DOWN PROCESSOR ALIVE FLAGS
708: 
709: RSCHED: CONO    PI,APROFF               ;SHUT OFF THE REAL-TIME CLOCK
710:         SKIPN   TIMEFF(PID)             ;ARE WE BEHIND IN TIME ACCOUNTING?
711:         JRST    CIP6                    ;NO, JUST RESCHEDULE
712:         SETZM   TIMEFF(PID)             ;DECREMENT "BEHIND" COUNT
713:         CONO    PI,APRON                ;ENABLE CHANNEL 3 AGAIN
714:         SETOM   TIMEF(PID)              ;SET "TIME" FLAG
715:         MOVE    TAC,OTHERID(PID)
716:         SOS     PALIVE(TAC)
717:         MOVEI   TAC,30
718:         MOVEM   TAC,PALIVE(PID)
719: 
720:         JUMPN   PID,MIDCHK              ;FLUSH PDP6
721:         SOSLE   T15CNT          ;TIME TO CHECK FOR AUDIO SWITCH?
722:         JRST    SECCHK
723: ;HERE EVERY 1/4 TH SECOND
724:         MOVEI   TAC1,=15
725:         MOVEM   TAC1,T15CNT
726:         PUSHJ   P,ASSCN         ;SEE IF ANY AUDIO SWITCH WORK TO BE DONE(TTYSER)
727: SECCHK: SOSLE   DKBCNT          ;TIME TO RUN THE 1 SECOND CLOCK?
728:         JRST    MIDCHK          ;NO
729: ;HERE ONCE PER SECOND. 
730:         MOVEI   TAC1,=60        ;CHECK EVERY SECOND
731:         MOVEM   TAC1,DKBCNT     ;RESTORE COUNT WORD (IN APRDAT)
732:         MOVE    TAC,TIME        ;GET CURRENT TIME
733:         IDIVI   TAC,=60         ; AND CONVERT IT TO SECONDS
734:         HRL     TAC,THSDAT      ; PUT DATE IN LEFT HALF
735:         MOVEM   TAC,TIMDAT      ;SAVE <DATE>,,<TIME IN SECS>
736: ;HERE WE MAKE SURE THAT KEY NXM STOP IS ON.  PROCESSOR REALLY LOSES
737: ;WHEN IT GETS A NXM, SO ... REG 8-14-73
738:         CONSZ   PTP,200         ;SKIP IF KEY NXM STOP IS OFF.
739:         JRST    DDSTAT          ;IS OK.
740:         PUSHACS
741:         PUSHJ   P,DISDATE
742:         PUSHJ   P,DISMES
743:         ASCIZ   /πππTURN NXM STOP ON!
744: /
745:         CONO    PI,PIOFF        ;NOW SO WE REALLY MAKE OURSELVES NASTY
746:         PUSHJ   P,DISFLUSH
747:         CONSO   PTP,200
748:         JRST    .-1             ;WAIT UNTIL SOMEONE NOTICES.
749:         CONO    PI,PION
750:         POPACS
751: DDSTAT:
752: IFN FTDDSTAT,<
753:         SOSLE   NDSTAT          ;TIME FOR DD STATISTICS?
754:         JRST    SCNPIC          ;NO. CHECK THE SCANNER NEXT
755:         MOVEI   TAC,5           ;HERE EVERY 5 SECONDS
756:         MOVEM   TAC,NDSTAT
757: 
758:         MOVE    TAC,NDDXCT      ;GET NEW COUNT
759:         EXCH    TAC,NDDXOL      ;STORE AS OLD COUNT
760:         SUB     TAC,NDDXOL      ;OLD COUNT - NEW COUNT. RESULT NEGATIVE
761:         MOVN    TAC,TAC
762:         CAMLE   TAC,NDDXMX      ;BIGGER THAN OLD MAX?
763:         MOVEM   TAC,NDDXMX      ;YES. STORE NEW MAX.
764: 
765:         MOVE    TAC,NDDLCT      ;GET NEW COUNT
766:         EXCH    TAC,NDDLOL      ;STORE AS OLD COUNT
767:         SUB     TAC,NDDLOL      ;OLD-NEW. RESULT IS POSITIVE.
768:         CAMLE   TAC,NDDLMX      ;BIGGER THAN OLD MAXIMUM?
769:         MOVEM   TAC,NDDLMX      ;YES. STORE NEW MAX.
770: >                               ;END FTDDSTAT
771: ;SCANNER PI CHN CHECK - TEMP. FIX TO HARDWARE PROBLEM - 12 JUNE 72 - JHS
772: SCNPIC: CONI    DKB,TAC1
773:         ANDI    TAC1,7
774:         CAIN    TAC1,SCNCHN     ;DOES DKB STILL THINK IT'S ON CHANNEL 5?
775:         JRST    MIDCHK          ;  YES
776:         CONO    DKB,10!SCNCHN   ;  SET PI'S AND RESET FOR GOOD MEASURE
777:         PUSHACS
778:         PUSHJ   P,DISDATE
779:         PUSHJ   P,DISMES
780:         ASCIZ   /SCANNER LOST PI CHANNEL AGAIN!
781: /
782:         POPACS
783: MIDCHK:
784: 
785: ;MIDNITE CHECK
786: 
787:         CONO    PI,APROFF               ;HOLD UP CHANNEL 3
788:         MOVE    TAC1,TIME(PID)
789:         CAMGE   TAC1,MIDNIT             ;GONE PAST MIDNITE?
790:         JRST    CIP2                    ;NO
791:         SUB     TAC1,MIDNIT             ;KEEP COUNT ACCURATE
792:         MOVEM   TAC1,TIME(PID)          ;REPLACE COUNT
793:         CONO    PI,APRON                ;ENABLE CHANNEL 3 AGAIN
794: CIP3:   MOVEI   IOS,0                   ;RESET IOS ALSO.
795:         AOS     TAC,THSDAT(PID)         ;UPDATE DAY.
796:         IDIVI   TAC,=31
797:         DIVI    IOS,=12                 ;NO.
798:         LDB     IOS,PMONTB
799:         CAMGE   IOS,TAC1                ;END OF MONTH?
800:         JRST    CIP3                    ;YES.
801: 
802: ;       SETZM   AFOOL                   ;THESE 4 INSTR. FOR APRIL 1 HACK.
803: ;       JUMPN   TAC1,CIP2               
804: ;       CAIN    TAC,3
805: ;       SETOM   AFOOL
806: 
807: CIP2:   CONO    PI,APRON                ;ENABLE CLOCK TRAPS AGAIN
808:         JUMPN   PID,CIPZZ1              ;SKIP THIS STUFF ON THE PDP-6
809:         HGMAC   (21)
810:         SOSLE   FSCKCT
811:         SKIPE   FSNCLK
812:         PUSHJ   P,FSCLK                 ;THINK ABOUT FREE STORAGE.
813:         SKIPLE  SPFSNT
814:         PUSHJ   P,SFSCLK                ;REPLENISH SPARE LISTS IF NECESSARY
815: IFG DPYNUM,<                            ;MAINTAIN DISPLAYS
816:         PUSHJ   PDP,DPYCLK
817: IFN IMPSW,<     HGMAC   (23)
818:                 PUSHJ   P,IMPCLK>
819:         HGMAC   (14)
820:         JUMPE   PID,CIPZZ1
821:         PUSHJ   P,DISMES
822:         ASCIZ   /πPID CLOBBERED BY DPYCLK OR TTYCLK
823: /
824:         MOVEI   PID,P1PID               ;WHICH IS KNOWN TO BE ZERO
825: >
826: CIPZZ1: HGMAC   (0)
    CLKSER page# 0017 next  prev
828: ; KEEP INFORMATION FLOWING BETWEEN THE PROCESSORS
829: ; MODIFIED CLOCK ROUTINES FOR 2-PROCESSOR SYSTEM
830: 
831:         JUMPE   PID,JLCALC
832:         PUSHJ   P,JLCAL         ;CALCULATE JOB LOADING
833:         PUSHJ   P,SPWP2         ;DO SPACEWAR
834:         PUSHJ   P,WHOSER        ;CALCULATE WHO LINES
835:         PUSHJ   P,PTRP2         ;KEEP PAPERTAPE READER ALIVE
836:         PUSHJ   P,PTPP2         ;KEEP TAPE PUNCH/PLOTTER GOING
837:         PUSHJ   P,ADP2          ;AND THE AD
838:         SOSG    XGPP2F          ;COUNT DOWN TO RUN XGP CLOCK LEVEL.
839:         PUSHJ   P,XGPP2         ;AND THE XGP
840:         SKIPE   ADCP2L          ; ADC?
841:         PUSHJ   P,ADCP2
842:         SKIPE   DACP2L
843:         PUSHJ   P,DACP2
844: 
845: IFN 0,< ;THIS PROBLEM HAS BEEN FIXED?
846:         SKIPL   AC2,NULDAT+P2PID+JOBDAC+10      ;THE ONE THAT GETS IT
847:         TDNN    AC2,[140000,,140000]    ;MAY HAVE COUNTED DOWN TO NEXT BIT
848:         JRST    NULOK
849:         PUSHJ   P,DISMES
850:         ASCIZ   /100000 BIT PICKED: /   ;SO GJG WILL KNOW
851:         TLNN    AC2,140000
852:         JRST    NULLOK
853:         PUSHJ   P,DISMES
854:         ASCIZ   /LEFT /
855:         JRST    NULROK
856: NULLOK: PUSHJ   P,DISMES
857:         ASCIZ   /RIGHT /
858: NULROK: SETZM   NULDAT+P2PID+JOBDAC+10  ;RESTART IT
859:         PUSHJ   P,DISMES
860:         ASCIZ /HALF.
861: /
862: >       ;END IFN 0,
863: 
864: NULOK:  SOSL    CRKYET          ; TIME TO READ THE CROK AGAIN?
865:         JRST    CRKT4           ; NO, SKIP IT
866:         MOVEI   TAC,=3600*5     ; SET FOR 5 MINS
867:         MOVEM   TAC,CRKYET
868:         MOVEI   TAC1,5          ; WE WILL TRY FIVE TIMES
869:         PUSHJ   PDP,DAT2        ; READ PETIT CROCK
870:         JRST    CRKT4           ; NO, CRK SICK
871:         MOVEM   ITEM,CRKTIM     ; UPDATE TIME OF DAY
872:         MOVEM   DAT,CRKDAT      ; UPDATE DATE
873:         JRST    CRKT4
874: 
875: JLCALC: HGMAC   (16)
876:         MOVE    TAC,OTHERID(PID)
877:         SKIPE   P2NUM
878:         SKIPGE  PALIVE(TAC)
879:         PUSHJ   P,JLCAL         ; RECOMPUTE PRIORITIES
880: JORD:   SKIPE   ORDYET
881:         PUSHJ   P,ORDER         ; SORT THE JOBS IN THE RUN QUEUE INTO PRIORITY ORDER
    CLKSER page# 0018 next  prev
883: ; HERE IS THE GUY THAT CALLS UP PHANTOM PROCESSES LIKE BATCH MONITORS
884: 
885: IFN FTBAT,<
886:         SOSLE   BATYET          ;RUN OUR BATCH JOB YET?
887:         JRST    BAT3A           ;NO. NOT YET
888:         HGMAC   (0)
889:         MOVEI   TAC,=60*JIFSEC  ;RESET TO LOOK AGAIN IN 1 MINUTE
890:         MOVEM   TAC,BATYET      ;SET RETRY TIME
891:         SKIPE   MAINTM          ;MAINTMODE?
892:         JRST    BAT3A           ;FLUSH THIS CODE WHILE MAINTM SET
893:         MOVSI   TAC,-BATLEN     ;LENGTH OF BATMAN
894: BATLOP: MOVEM   TAC,BATPNT      ;SAVE IT
895:         SKIPE   AC1,BATMAN(TAC) ;JOBNAM
896:         SKIPN   AC3,ROBIN(TAC)  ;PPN
897:         JRST    BAT3            ;AVOID EMBARASSING CONFUSION!
898:         SKIPGE  J,ALFRED(TAC)   ;GET CIRCUMSTANTIAL CODE
899:         JRST    BAT3            ;NEGATIVE MEANS DON'T START ME
900:         JUMPE   J,BAT0          ;IF ZERO THEN START ME!
901:         MOVE    TAC,TIME        ;GET JIFFIE TIME
902:         IDIVI   TAC,=60*JIFSEC  ;MAKE IT MINUTES
903:         HRL     TAC,THSDAT      ;GET THE DATE
904:         CAMGE   TAC,ITEM        ;COMPARE WITH HIS REQUEST
905:         JRST    BAT3            ;NOT YET.
906:         HRRZ    TAC,BATPNT      ;GET CURRENT POINTER BACK
907:         SETZM   ALFRED(TAC)     ;SO WE DON'T GET HERE AGAIN
908: BAT0:   MOVEI   J,JOBN-1        ;SCAN JOBS LOOKING FOR ONE LIKE THIS.
909:         MOVSI   TAC,JNA
910: BAT1:   TDNN    TAC,JBTSTS(J)   ;IS THERE A JOB HERE?
911:         JRST    BAT2            ;NO.
912:         CAMN    AC1,JOBNAM(J)   ;WITH A NAME LIKE MINE?
913:         CAME    AC3,PRJPRG(J)   ;AND A PPN LIKE MINE TOO?
914:         JRST    BAT2            ;NO MATCH.
915:         SKIPL   AC2,JBTSTS(J)   ;IS THIS JOB RUNNABLE?
916:         TLNE    AC2,JLOG        ;NOT RUNNABLE. IS IT LOGGED IN?
917:         JRST    BAT3            ;RUNNABLE OR LOGGED IN.
918: ;HERE WE HAVE A DEAD PHANTOM.  KILL IT AND START A NEW ONE.
919: ;TO BE CONTINUED....
920:         JRST    BAT3            ;TO BE CONTINUED. IN THE MEANTIME, DO NOTHING.
921: 
922: BAT2:   SOJG    J,BAT1          ;LOOP LOOKING THRU ALL JOBS.
923:         PUSHJ   P,INIJOB        ;ATTEMPT TO MAKE A NEW JOB
924:         JRST    BAT3A           ;NONE AVAILABLE. MAYBE SOON...
925:         JRST    BAT3B           ;AVAILABLE LATER...
926: 
927: BAT4:   PUSHJ   P,GETBAT        ;START A PHANTOM JOB.
928: BAT3:   MOVE    TAC,BATPNT      ;GET BACK BAT POINTER
929:         AOBJN   TAC,BATLOP
930:         JRST    BAT3A           ;DONE
931: BAT3B:  MOVEI   TAC,=60         ;WAIT FOR ONE SECOND
932:         MOVEM   TAC,BATYET
933: BAT3A:                          ;DONE WITH PHANTOM CHECKS FOR THIS MINUTE.
934: >;END OF FTBAT
    CLKSER page# 0019 next  prev
936: ; MAINTAIN P1'S 2-PROCESSOR COMMUNICATION
937: 
938:         HGMAC(0)
939:         CONI    TV,SPWBUT       ;READ THE SPACEWAR BUTTONS
940:         SKIPE   SPWGO           ;ONLY RUN SPACEWAR IF SOMEONE WANTS IT
941:         PUSHJ   P,SPWP1         ;RUN SPACEWAR OFF THE CLOCK
942:         MOVE TAC,OTHERID(PID)   ; PICK UP ADDRESS OF PDP-6'S DATA AREA
943:         SKIPGE PALIVE(TAC)      ; IS SIX RUNNING?
944:         PUSHJ P,WHOSER          ; APPARANTLY NOT. REFRESH WHO LINE.
945:         SKIPN P2NUM             ; DOES P2 EXIST?
946:         JRST CRKT2              ; NO, FORGET IT
947: 
948:         SKIPE   PARFLG          ; PARITY ERROR ON P2?
949:         PUSHJ   P,PARCLK        ;YES. CALL PARITY ERROR SERVICE
950: 
951: CRKT3:  MOVE ITEM,CRKTIM        ; PICK UP TIME OF DAY
952:         SKIPN DAT,CRKDAT        ; IS THE CRK RUNNING? DATES AREN'T = 0
953:         JRST CRKT1              ; CRK DEAD, FORGET IT.
954:         MOVEM ITEM,TIME(PID)    ; UPDATE TIME OF DAY
955:         MOVEM DAT,THSDAT(PID)   ; UPDATE DATE
956:         SETZM CRKDAT            ; CLEAR DATE FLAG
957: 
958: CRKT1:  SKIPE   PTRADV          ;RUN CLOCKS FOR PTR,PTP,AD AND XGP
959:         PUSHJ   P,PTRP1
960: 
961:         SKIPE   PTPSID
962:         PUSHJ   P,PTPP1
963: 
964:         SKIPLE  ADADV
965:         PUSHJ   P,ADP1
966: 
967:         SKIPE   XGPP1F          ;DO WE HAVE TO LOOK AT XGP STATUS?
968:         PUSHJ   P,XGPP1         ;YES.
969: 
970:         SKIPE   ADCP1L          ; ADC CALLING?
971:         PUSHJ   P,ADCP1         ; YES
972: 
973:         SKIPE   DACP1L          ; DAC MAYBE?
974:         PUSHJ   P,DACP1
975: 
976: REPEAT 0,<                      ;ABOUT TIME THIS CROCK WAS FLUSHED
977:         HGMAC(20)               ;HGCODE FOR SCHCLK, REPLACED BY THE FOLLOWING:
978:         SKIPGE  J,JBTQ-DIOWQ    ;ANYONE IN QUEUE?
979:         JRST    CRKT2           ;NOPE.
980:         AOS     JBTRNB(J)       ;COUNT TIME (WHAT A CROCK!)
981:         HRRE    J,JBTQ(J)       ;GET NEXT GUY IN Q.
982:         JUMPGE  J,.-2           ;JUMP IF REAL JOB THERE.
983: >
984:         JRST    CRKT2
    CLKSER page# 0020 next  prev
986: ; HERE IS SUBROUTINE FOR PHANTOM ROUTINES
987: 
988: IFN FTBAT,<
989: GETBT0:                        ;ENTER HERE FROM CLKREQ BY XGPSER
990:         MOVE    J,TAC           ;JNA FOR THIS JOB IS TURNED ON ALREADY.
991:         JRST    GETBTX
992: 
993: GETBAT:
994:         SKIPE MAINTMODE
995:         POPJ P,
996:         MOVE TAC,BATPNT         ;GET THE POINTER TO BAT TABLES
997:         MOVE TAC,GORDON(TAC)    ;GET THIS PHANTOM'S PRIVILEGE BITS
998:         MOVEM TAC,JBTPRV(J)     ;SAVE
999:         MOVEM TAC,JB2PRV(J)     ;ALSO IN PASSIVE BITS
1000:         MOVEM AC3,PRJPRG(J)
1001:         MOVEM AC3,JOBPPN(J)
1002:         MOVEM AC1,JOBNAM(J)     ;SETUP THIS GUY'S NAME
1003: IFN FTSTAT,<PUSHJ P,NAMSTT>
1004:         MOVSI TAC,JNA           ;MAKE SURE NO ONE GETS THIS NUMBER
1005:         ORM TAC,JBTSTS(J)
1006: GETBTX: MOVSI TAC,'DSK'         ;DEVICE DISK. 
1007:         MOVEM TAC,JOBDEV(J)
1008:         MOVSI TAC,'DMP'         ;AND DUMP
1009:         MOVEM TAC,JOBLOG(J)
1010:         SETZM JOBCRD(J)         ;NO CORE SIZE OR STARTING INCREMENT
1011:         SETZM JBTUFD(J)
1012: IFN FTDSKPPN,<SETZM DSKPPN(J)   ;INITIALIZE DISK ALIAS PPN>
1013:         SETZM JBTKCJ(J)
1014:         MOVSI TAC,JLOG
1015:         ANDCAM TAC,JBTSTS(J)
1016:         HLLZS SAVSAI(J)         ;JUST IN CASE
1017: GETBT1: SETOM TAC1
1018:         PUSHJ P,DDBSRC
1019:         JRST DELBTT             ; NO DDB, DELAY
1020: GETBT2: SETZ PROG,
1021:         MOVEI TAC,JOBDA
1022:         PUSHJ P,CORE0           ; GET IT SOME CORE
1023:         JRST DELBAT             ; NOT AVAILABLE, WAIT FOR IT
1024: GETBT3: MOVSI TAC,SWP!SHF
1025:         SKIPN XJOB(J)           ; IF STILL GETTING CORE, DELAY A WHILE
1026:         TDNE TAC,JBTSTS(J)      ; DID JOB GO AWAY DURING ALL THIS?
1027:         JRST BATSWP             ; YES, GET IT BACK IN
1028: BATSW:         ;ENTER HERE FROM SWAPPER WHEN JOB COMES IN
1029:         PUSHJ P,SETLOG          ; SET-UP LOGIN STUFF
1030:         MOVE TAC,JOBNAM(J)
1031:         MOVEM TAC,FILNAM(PROG)
1032:         MOVE TAC,JOBDEV(J)      ; DEVICE
1033:         MOVEM TAC,DEVWRD(PROG)
1034:         HLLZ TAC,JOBLOG(J)      ; EXTENSION
1035:         MOVEM TAC,FILEXT(PROG)
1036:         SKIPN TAC,JOBCRD(J)             ; CORE SIZE
1037:         JRST .+3                        ; DON'T FUTZ WITH ZERO
1038:         LSH TAC,12                      ; TO WORDS
1039:         SUBI TAC,1                      ;TO PROT
1040:         MOVEM TAC,JOBCOR(PROG)
1041:         HRRZ TAC,JOBLOG(J)
1042:         MOVEM TAC,INCWRD(JDAT)  ;SAVE IN PLACE WE CAN FIND IT LATER
1043:         MOVEI TAC1,PRUNJB       ; THIS GUY KNOWS ABOUT INCREMENTAL START-UP
1044:         JRST MONJOB
    CLKSER page# 0021 next  prev
1046: ; MORE PHANTOM CLOCK LEVEL ROUTINES, WAITING FOR RESOURCES
1047: 
1048: DELBAT: LSH J,=12               ; HERE WE WAIT FOR CORE TO BECOME AVAILABLE
1049:         ADD J,[XWD BATRS,1]
1050: DELB1:  CONO PI,PIOFF
1051:         IDPB J,CLOCK(PID)
1052:         CONO PI,PION
1053:         POPJ P,
1054: 
1055: BATRS:  MOVE J,TAC
1056:         JRST GETBT2
1057: 
1058: DELBTT: LSH J,=12
1059:         ADD J,[XWD BATTT,1]
1060:         JRST DELB1
1061: 
1062: BATTT:  MOVE J,TAC
1063:         JRST GETBT1
1064: 
1065: BATSWP: MOVSI TAC,BATSNB        ; SET THIS FLAG AND PUT IN SWAPIN LIST
1066:         JRST SETSIN             ; WILL CALL BATSW WHEN SWAPPED IN
1067: 
1068: ;THERE ARE 3 TABLES IN APRDAT OF EQUAL LENGTH WHICH CONTAIN THE NAMES OF
1069: ;ALL THE PHANTOM JOBS AND A FLAG TO TELL IF THIS JOB SHOULD BE
1070: ;STARTED AT ALL THE JOBS ARE STARTED WHEN THE SYSTEM STARTS UP AND
1071: ;CHECKED FOR RESTART EVERY MINUTE.
1072: >;END OF FTBAT
    CLKSER page# 0022 next  prev
1074: ; HERE WE FLUSH THE DISASTER TYPEOUT BUFFER THEN PROCESS CLOCK REQUESTS
1075: 
1076: CRKT2:  HGMAC(0)
1077:         MOVE TAC,DISPTR
1078:         CAME TAC,DISOPT         ; ANYTHING IN THE DISASTER BUFFER?
1079:         PUSHJ P,DISOUT          ; YES, GO EMPTY IT
1080: 
1081: ;PROCESS TIMING REQUESTS STORED IN QUEUE
1082: 
1083: CRKT4:  HGMAC   (17)            ;TIMING REQUEST.
1084:         HRRZ DAT,CLOCK(PID)     ;GET END OF LIST
1085: CIP4:   CAIG DAT,CIPWT-1(PID)   ;END YET?
1086:         JRST CIP5               ;YES
1087:         SOS TAC1, (DAT)         ;DECREMENT TIMING REQUEST
1088:         TRNE TAC1, 7777         ;TIME EXPIRED YET
1089:         SOJA DAT, CIP4          ;NO, CONTINUE SCAN
1090:         CONO PI, PIOFF          ;YES, MOVE LAST ITEM IN LIST TO THIS
1091:         MOVE TAC, @CLOCK(PID)
1092:         SOS CLOCK(PID)
1093:         MOVEM TAC, (DAT)
1094:         CONO PI,PION
1095:         LDB TAC, [POINT 6, TAC1, 23]
1096:                                 ;GET 6 BIT DATA ITEM
1097:         HLRZS TAC1              ; SETUP DISPATCH ADDRESS
1098:         CAMG TAC1,SYSTOP        ; IS THIS A REASONABLE ADDRESS?
1099:         JRST CIP5AA
1100:         PUSH P,DAT
1101:         PUSHJ P,ALTNOW
1102:         JFCL
1103:         PUSHJ P,DISDATE
1104:         PUSHJ P,DISMES
1105:         ASCIZ /ππCLOCK REQUEST WITH ILLEGAL ADDRESS
1106: /
1107:         POP P,DAT
1108:         SKIPN DISFLAG
1109:         JRST CIP5A
1110:         PUSHJ P,DISFLUSH
1111:         JRST AUTOLOAD
1112: 
1113: CIP5AA: PUSH PDP, DAT           ;SAVE ONLY VALUABLE AC
1114: IFN FTHG, <PUSH P,HGCODE 
1115:            HGMAC(22)    >
1116:         PUSHJ PDP, (TAC1)       ;AND DISPATCH TO TIMING REQUEST ROUTINE
1117: IFN FTHG, <POP  P,HGCODE >
1118:         POP PDP, DAT
1119: CIP5A:  SOJA DAT, CIP4          ;GO BACK FOR MORE REQUESTS
    CLKSER page# 0023 next  prev
1121: ; IF WE ARE SHUFFLING 1K AT A TIME, DO ANOTHER K HERE, THEN CALL SCHEDULER
1122: 
1123: CIP5:   JUMPN PID,CIP6A         ;P2 JUMPS TO CIP6A -AVOID RUNNING COMMAND
1124: IFN FTSHF1K,<
1125:         HGMAC   (13)
1126:         SKIPN TAC,SHFTAC        ;ANY SHUFFLING TO DO?
1127:         JRST CIP11              ;NO.
1128:         MOVE ITEM,SHFJOB        ;LOAD NUMBER OF JOB TO BE MOVED
1129:         HRRZ TAC1,TAC           ;YES. DO 1K OF IT.
1130:         CAML TAC1,SHFEND        ;ARE WE DONE?
1131:         JRST CIP12              ;YES.
1132:         BLT TAC,1777(TAC1)      ;MOVE THAT CORE.
1133:         MOVE TAC,[XWD 2000,2000]
1134:         ADDM TAC,SHFTAC         ;UPDATE SHFTAC
1135:         HRRZ TAC,SHFTAC         ;WAS THAT THE LAST?
1136:         CAMGE TAC,SHFEND
1137:         JRST CIP11
1138: CIP12:  PUSHJ P,NOTSH1          ; FINISHED. MARK IT DONE.
1139:         PUSHJ P,SHFDONE
1140: >       ;END OF IFN FTSHF1K
1141: 
1142: CIP11:  HGMAC(11)
1143:         SOSG HNGTIM             ;DECREMENT HUNG IO DEVICE 
1144:         PUSHJ PDP,DEVCHK        ;GO CHECK FOR HUNG IO DEVICES
1145: CIP6:   CONO PI,APRON           ; ENABLE CLOCK TRAPS IF THEY WERE OFF
1146:         HGMAC(1)
1147:         SKIPE COMCNT            ;ANY COMMANDS TO PROCESS?
1148:         PUSHJ PDP,COMMAND       ;YES, CALL COMMAND DECODER.
1149:         HGMAC(6)
1150: CIP6A:  PUSHJ PDP,NXTJOB        ;CALL SCHEDULER
1151:         HGMAC(15)
1152:         SETZM SCHEDF(PID)       ;CLEAR FORCED SCHEDULING FLAG
1153:         SETZM TIMEF(PID)        ;CLEAR "CLOCK FIRED" FLAG
1154:         JUMPN J,CLKSRJ          ; IF NULL JOB RUNNING, DO FOLLOWING TEST
1155:         JUMPN PID,CLKSRJ
1156:         MOVE AC1,[XWD -RUNQ,-RUNQ]
1157:         MOVE AC2,[XWD -TQ,-TQ]
1158:         CAMN AC1,JBTQ-RUNQ
1159:         CAME AC2,JBTQ-TQ        ; IF ANYBODY RUNNABLE, BUMP COUNT
1160:         AOS NJRNULLS
1161: CLKSRJ: MOVEI   TAC1,1          ;THIS BIT WILL REPRESENT THE NEW JOB
1162:         SETZ    TAC,            ; SOMEWHERE IN TAC OR TAC1
1163:         LSHC    TAC,(J)         ;MOVE BIT TO APPROPRIATE POSITION
1164:         ORM     TAC,JBSRUN      ; AND NOTE THIS JOB HAS BEEN RUN LATELY
1165:         ORM     TAC1,JBSRUN+1
1166: 
1167:         CAMN ITEM,JOB(PID)      ;IS NEXT JOB SAME AS LAST ONE?
1168:         JRST CIP8               ;YES, JUST RESTORE ACS AND DISMISS
1169:         SKIPE ITEM              ; ARE WE SWITCHING TO THE NULL JOB?
1170:         AOS NJSWITCHES          ; NO, MARK ANOTHER SWITCHING
    CLKSER page# 0024 next  prev
1172: ;DIFFERENT JOB, SAVE SOFTWARE STATE(HARDWARE ALREADY SAVED)
1173: 
1174:         MOVE    JDAT,JOB(PID)   ;GET OLD JOB NUMBER
1175:         MOVE    TAC,TIMDAT      ;GET <DATE>,,<TIME IN SECS>
1176:         MOVEM   TAC,FTIME(JDAT) ;AND SAVE FOR JOB THAT JUST RAN
1177: 
1178:         SKIPE JDAT,JOBDAT(PID)  ;NULL JOB OR CORE 0 ON OLD JOB?
1179:         PUSHJ P,S2U             ; MOVE CHANNEL ASSIGNMENTS INTO USER CORE
1180: NULJOB:                        ;TRANSFER HERE FROM SYSINI WITH ITEM=0
1181: CIP7:   MOVEM ITEM,JOB(PID)     ;STORE NEW CURRENT JOB NUMBER
1182:         MOVE PROG,JBTADR(ITEM)  ;RELOCATION FOR CURRETN JOB
1183:         MOVEM PROG,JOBADR(PID)  ;XWD PROTEC,RELOC
1184: IFN JDMPRG,<
1185:         MOVE JDAT,JBTDAT(ITEM)  ;LOC. OF JOB DATA AREA
1186:         MOVEM JDAT,JOBDAT(PID)  ;FOR CURRENT JOB
1187: >
1188:         CONO APR,550+APRCHN     ; CLEAR APR ENABLED FLAGS
1189:         HLLZS APRIN1(PID)       ;DISABLE USER APR INTERRUPTS
1190:         SETZM APRIN3(PID)
1191:         JUMPE ITEM,NULJB        ;IS NEW JOB NULL JOB?
1192:         HLRZM PROG,USRREL(PID)  ;PROTECTION FOR CURRENT JOB
1193:         HLRZM PROG,JOBREL(JDAT) ;SET PROT. IN JOB DATA AREA FOR USER TO LOOK AT
1194:         PUSHJ P,U2S             ; MOVE USER TABLE INTO SYSTEM
1195:         MOVE TAC,JBTIEN(J)      ; PICK UP USER INTERRUPT ENABLINGS
1196:         ANDI TAC,CPUMSK
1197:         MOVEM TAC,APRIN2(PID)   ; SET SO CH3 CAN TEST FOR THEM
1198:         IOR TAC,JOBENB(JDAT)    ;NOW INCLUDE OLD-STYLE INTS
1199:         ANDI TAC,CPUMSK!1000    ; SYSTEM ENABLED FOR PDL OV, ILM, NXM, CLK
1200:         HRRM TAC,APRIN1(PID)    ; PUT IN USER ENABLED LOC
1201:         XORI TAC,110            ; COMPLEMENT FOV, AROV, SO 0 MEANS ENABLE
1202:                                 ; AND 1 MEANS DISABLE
1203:         ADDI TAC,330            ; SET BITS 27 AND 30 IF DISABLE
1204:                                 ; SET BITS 28 AND 31 IF ENABLE
1205:         ANDI TAC,660            ;MASK OUT ALL BUT PC CHNG+AROVF ENABLE-DISABLE
1206:         CONO APR,APRCHN(TAC)    ;ENABLE OR DISABLE PC CHNG AND AR OVF
1207:         JRST CIP8               ; JUMP TO PAGE AFTER NEXT
    CLKSER page# 0025 next  prev
1209: ;S2U AND U2S
1210: S2U:    MOVEI TAC,JOBPRT(JDAT)  ;DEST.=FIRST LOC PROTECTED FROM USER
1211:         HRLI TAC,USRPRT(PID)    ;SOUR.=SYSTEM DATA STORAGE FOR CURRETN JOB
1212:         SKIPL TAC1,USRHCU(PID)
1213:         JRST CIP14
1214:         SUBI JDAT,2
1215:         JRST CIP13
1216: CIP14:  CAILE TAC1,17           ;MUST BE 17 OR LESS(IO MIGHT
1217:                                 ;CLOBBER IF ADDRESS CHECKING MISSES)
1218:         MOVEI TAC1,17           ;MOVE ALL 20 CHANNELS IF NEG.
1219:                                 ;OR LESS THAN 0.
1220:         ADD JDAT,TAC1           ;RELOCATE TO USER AREA
1221: CIP13:  BLT TAC,JOBJDA(JDAT)    ;MOVE TO USER JOB DATA AREA
1222:                                 ;STOP WITH USER CHANNEL 0-1+C(USRHCU)
1223:         POPJ P,
1224: 
1225: U2S:    MOVEI TAC,USRPRT(PID)   ;DEST.=PROTECTED AREA IN MONITOR
1226:         HRLI TAC,JOBPRT(JDAT)   ;SOURCE=FIRST PROTECTED LOC. IN JB  DATA AREA
1227:         SKIPL TAC1,JOBHCU(JDAT) ;MOVE NO. OF USER IO CHAN. IN USE
1228:         CAILE TAC1,17           ;MUST BE 17 OR LESS(IO MIGHT CLOBBER
1229:                                 ;IF ADRRESS CHECKING MISSES
1230:         MOVEI TAC1,17           ;MOVE ALL 20 CHAN. IF NEG. OR GREATER THAN 17
1231:         BLT TAC,USRJDA(TAC1)    ;AND MOVE INTO MONITOR
1232:         POPJ P,
    CLKSER page# 0026 next  prev
1234: ;RESTORE HARDWARE STATE OF CURRENT JOB
1235: 
1236: CIP8:   JUMPE PID,CIP8A
1237:         JUMPE ITEM,CIP8A
1238:         PUSHACS
1239:         PUSHJ P,DISMES
1240:         ASCIZ /ππPDP-6 ATTEMPTING TO RUN JOB!
1241: /
1242:         POPACS
1243:         SETZB ITEM,JOB(PID)     ;MAKE SURE IT IS THE NULL JOB!!!!!!!!
1244:         JRST NULJB
1245: CIP8A:  PUSHJ P,GETPR
1246:         DATAO APR,TAC
1247: IFN FTSWAP,<
1248:         SETOM STIME(ITEM)       ; MARK THAT THIS JOB HAS BEEN RUN
1249:         LDB TAC,PSEGN           ; AND MARK HIGH SEGMENT TOO
1250:         MOVE TAC1,JBTSTS(TAC)   ; IF IT IS NOT WRITE-PROTECTED
1251:         TLNN TAC1,JWP
1252:         SETOM STIME(TAC)        ; IF WRITE-ENABLED, MARK USED.
1253: >
1254:         SKIPE JDAT,JBTDAT(ITEM) ;JOB DATA AREA(IS THERE ONE?)
1255:         JRST CIP8B
1256:         SKIPE NULBAD(PID)       ; IS THE NULL JOB SICK?
1257:         JRST NULJB              ; YES, GO FIX IT
1258:         MOVEI JDAT,NULDAT(PID)  ;NO, MUST BE NULL JOB
1259: CIP8B:  MOVE TAC,JOBD17(JDAT)
1260:         MOVEM TAC,CLKS17(PID)
1261:         MOVSI 17,JOBDAC(JDAT)   ;RESTORE DUMP ACS
1262:         JUMPE PID,CIP8C
1263:         BLT 17,16
1264:         MOVE 17,[P2PID]
1265:         SKIPE APRERR(17)
1266:         JRST CLKERR
1267:         MOVE 17,CLKS17(17)
1268:         JEN @USRPC+P2PID
1269: CIP8C:  MOVN J,J
1270:         MOVSI TAC,400000
1271:         LSH TAC,(J)
1272:         DATAO PI,TAC
1273:         BLT 17,16
1274:         MOVE 17,[P1PID]
1275:         SKIPE APRERR(17)                ;ERROR IN THE EXEC?
1276:         JRST CLKERR                     ;YES. GO PROCESS.
1277:         MOVE 17,CLKS17(17)
1278:         JEN @USRPC+P1PID        ; RETURN TO USER.
1279: 
1280: PMONTB: POINT 6,MONTAB(TAC),5   ;POINTER TO NO. DAYS IN MONTH
    CLKSER page# 0027 next  prev
1282: ;THE NULL JOB
1283: ;RUNS IN USER MODE WITH PC=1 AND COUNTS IN AC 0
1284: 
1285: NULJB:  SOSL CHKYET(PID)
1286:         JRST NULJB1
1287:         MOVEI TAC1,=1000        ; ONLY CHECKSUM EVERY THOUSAND TIMES
1288:         MOVEM TAC1,CHKYET(PID)
1289:         PUSHJ P,SYSFIX          ;CHECK FOR ERROR AND FIX
1290:         JRST NULJB1             ;NO ERRORS
1291:         JFCL                    ;ERROR, BUT CAN'T FIX, FIX CHECKSUM
1292:         MOVE TAC,MONPTR         ;RECOMPUTE CHECKSUM, ERROR FIXED!
1293:         PUSHJ P,CHECK
1294:         MOVEM TAC1,MONSUM
1295: NULJB1: SETZM NULBAD(PID)
1296:         JUMPN PID,NULSIX
1297:         MOVSI 17,NULJ10         ; SET UP BLT TO ACCUMULATORS
1298:         BLT 17,NULL10           ; BLT IN ZINGHEIM'S NULL JOB
1299:         JRST 11,1               ;DISMISS IF INTERRUPT IN PROGRESS
1300: NULSIX: MOVSI 17,NULJ6
1301:         BLT 17,NULL6
1302:         JRST 11,1
1303: 
1304: NULJ10: 0
1305:         ROT 0,-1        ; RING AROUND THE ACCUMULATOR
1306:         TLNN 0,200000
1307:         TLC 0,400000
1308:         MOVEI 10,70000
1309:         SOJGE 10,5
1310:         JRST 1
1311: NULL10←←.-NULJ10
1312: 
1313: NULJ6:  0
1314:         ROT 0,1         ; RING AROUND THE ACCUMULATOR
1315:         TRNN 0,2
1316:         TRC 0,1
1317:         MOVEI 10,34000
1318:         SOJGE 10,5
1319:         XCT SIXRUN      ;TRAP IF CORE GETS CLEARED
1320:         JRST 1
1321: NULL6←←.-NULJ6
    CLKSER page# 0028 next  prev
1323: ; CHECKSUM ROUTINE. CALL WITH IOWD IN TAC, RETURNS CHECKSUM IN TAC1.
1324: 
1325: CHECK: MOVEI TAC1,0
1326:         JCRY0 .+1
1327:         ADD TAC1,(TAC)
1328:         JCRY0 [AOJA TAC1,.+1]
1329:         AOBJN TAC,.-2
1330:         HLRZ TAC,TAC1
1331:         HRRZS TAC1
1332:         ADD TAC1,TAC
1333:         TLZE TAC1,1
1334:         ADDI TAC1,1
1335:         POPJ PDP,
    CLKSER page# 0029 next  prev
1337: BEGIN   SYSFIX  ;VERIFY SYSTEM CHECKSUM AND FIX IT IF WRONG.
1338: ; ROUTINE TO RE-READ THE PROTECTED PART OF THE MONITOR FROM LIBRASCOPE
1339: ; CALLED BY:
1340: ;       PUSHJ P,SYSFIX
1341: ;       <NO ERRORS>
1342: ;       <ERROR, BUT COULDN'T FIX>
1343: ;       <ERRORS FIXED>
1344: 
1345: 
1346: ↑↑SYSFIX:
1347:         PUSH    P,TAC
1348:         PUSH    P,TAC1
1349:         MOVE    TAC,MONPTR
1350:         PUSHJ   P,CHECK         ;CHECKSUM MONITOR
1351:         CAME    TAC1,MONSUM     ;IS IT OK?
1352:         JRST    NOTOK
1353:         POP     P,TAC1
1354:         POP     P,TAC
1355:         POPJ    P,              ;ALL IS WELL
1356: 
1357: NOTOK:  POP     P,TAC1
1358:         POP     P,TAC
1359: ↑↑SYSCHK:
1360:         PUSHACS
1361:         PUSHJ   P,DISMES
1362:         ASCIZ   /⊗π⊗π⊗π⊗MONITOR CHECKSUM FAILURE.
1363: /
1364:         JUMPN   PID,SIXFIX      ;THE PDP-6 CANT FIX ANYTHING
1365:         CONSO   DSK,1B27        ;IS THERE ANY DISK TODAY?
1366:         SKIPN   SYSTHERE        ;IS THIS SYSTEM OUT THERE?
1367:         JRST    NOFIX
1368:         JRST    GOFIX           ;ATTEMPT TO FIX ERRORS
1369: 
1370: SIXFIX: SETZM   CHKYET+P1PID    ;TELL THE PDP-10 TO LOOK SOON
1371: NOFIX:  POPACS                  ;IF DISK IS OFF-LINE, NOTHING WE CAN DO.
1372:         JRST    CPOPJ1          ;TELL THEM NOTHING FIXED!
1373: 
1374: GOFIX:  SETOM   ERRYET          
1375: REPEAT 0,<                      ;12/1/73
1376:         CONI    APR,TAC         ;THE REMEMBER STATE OF SYS REF KLUGE
1377:         PUSH    P,TAC           ;THE ONLY WAY OUT GOES THRU FIXXIT
1378:         DATAO   PTR,[0]         ;SHUT OFF THE SYS REF KLUGE.
1379: >
1380:         CONSO   IOP,777770      ;IF NO BITS ON, IS IDLE.
1381:         JRST    IOPOK
1382:         MOVSI   UUO,1
1383:         CONSO   IOP,IOPJDN!IOPANY;IF JOB DONE, OR ANY ERROR IS UP, IS OK
1384:         SOJG    UUO,.-1         ;IF OTHER BITS ON BUT NOT JOB DONE, OR ERROR WAIT FOR IT
1385: IOPOK:  CONI    IOP,IOPSAV#     ;SAVE THE STATUS OF THE IOP
1386:         SKIPN   UUO,MONPTR      ;IOWD FOR THE PROTECTED PART OF THE MONITOR
1387:         JRST    FIXXIT          ;IF NOT SET UP YET, FORGET IT! (WHEREDAFUCKAREWE)
1388:         
1389:         HRRZ    AC1,UUO
1390:         LSH     AC1,-5          ;THIS SHOULD BE THE STARTING SECTOR COUNT
1391:         MOVEI   AC2,37
1392:         AND     AC2,UUO         ;GET OFFSET FOR FIRST 40 WORDS
1393:         SUBI    AC2,FIXLEN      ;AND THAT LEAVES....
1394:                                 ;READ FIXLEN WORDS AT A TIME AND COMPARE WITH MEMORY
1395: 
1396: DONXT:  MOVEI   AC3,40          ;WE WILL TRY THIS MENY TIMES
1397: DOAGIN: CONO    IOP,0
1398:         CONO    DSK,14000
1399:         DATAO   IOP,[XWD -FIXLEN,FIXBUF]
1400:         PUSH    P,AC1           ;SAVE SECTOR #
1401:         CAIL    AC1,2300        ;WRAP TO NEXT TRACK?
1402:         ADDI    AC1,1B24-2300   ;YES, ADJUST
1403:         ADD     AC1,SYSBAND
1404:         DATAO   DSK,AC1
1405:         POP     P,AC1           ;RESTORE SECTOR #
1406:         CONSO   IOP,IOPANY!IOPJDN;WAIT FOR IOP TO FINISH
1407:         JRST    .-1
1408:         CONSO   IOP,IOPANY      ;ANY ERRORS?
1409:         CONSZ   DSK,3370
1410:         SOJG    AC3,DOAGIN
1411:         JUMPLE  AC3,FIXXIT
1412: CHKWRD: AOJG    AC2,NXTCHK
1413:         MOVE    AC3,FIXBUF+FIXLEN-1(AC2)
1414:         CAME    AC3,(UUO)
1415:         JRST    PRNDIF          ;TELL THE WORLD!
1416: STRDON: AOBJN   UUO,CHKWRD
1417:         AOSLE   TAC,ERRYET      ;DONE WITH CHECK.
1418:         JRST    FIXXTB          ;THERE WERE ERRORS.
1419:         PUSHJ   P,DISMES
1420:         ASCIZ   /NO ERRORS FOUND.
1421: /
1422:         JRST    FIXXIT
1423: FIXXTB: PUSHJ   P,DISDCP
1424:         PUSHJ   P,DISMES
1425:         ASCIZ   /  ERRORS DETECTED.
1426: /
1427: FIXXIT: MOVE    UUO,IOPSAV      ;SUCCESS. NOW TRY TO PUT THE WORLD BACK.
1428:         TRNE    UUO,IOPJDN      ;IF JOB DONE IS ON, PUT UP DATA MISSED ALSO
1429:         TRO     UUO,IOPMIS      ;TO DO PREVIOUS TRANSFER OVER FOR GOOD MEASURE
1430:         CONO    IOP,(UUO)       ;SINCE WE FORGET THAT THERE WAS AN ERROR
1431: REPEAT 0,<
1432:         POP     P,TAC           ;RESTORE STATE OF SYS WR REF KLUGE
1433:         TRNE    TAC,SWRENB      ;WAS KLUGE ENABLED?
1434:         DATAO   PTR,[1]         ;YES. IT WAS. TURN IT BACK ON.
1435: >
1436:         POPACS
1437:         JRST    CPOPJ2
1438: 
1439: PRNDIF: PUSHACS
1440:         AOSLE   TAC,ERRYET
1441:         JRST    PRNDF1
1442:         PUSHJ   P,DISMES
1443:         ASCIZ   /LOC     CORE            DISK
1444: /
1445:         MOVEI   TAC,0
1446: PRNDF1: CAIL    TAC,10          ;ONLY PRINT THE FIRST 8 ERRORS
1447:         JRST    PRNDF2
1448:         MOVEI   TAC,(UUO)
1449:         PUSHJ   P,DISLOC
1450:         PUSHJ   P,DISMES
1451:         ASCIZ   /   /
1452:         MOVE    TAC,(UUO)
1453:         PUSHJ   P,DISOCT
1454:         PUSHJ   P,DISMES
1455:         ASCIZ   /    /
1456:         MOVE    TAC,AC3
1457:         PUSHJ   P,DISOCT
1458:         PUSHJ   P,DISCRLF
1459: PRNDF2: POPACS
1460:         MOVEM   AC3,(UUO)       ;FIX THE SYSTEM!
1461:         JRST    STRDON          ;AND CONTINUE LOOKING.
1462: 
1463: NXTCHK: ADDI    AC1,FIXNUM
1464:         MOVNI   AC2,FIXLEN              ;THIS MANY WORDS FROM NOW ON!
1465:         JRST    DONXT
1466: 
1467: 
1468: BEND SYSFIX
1469: SYSFIX←SYSFIX
    CLKSER page# 0030 next  prev
1471: ; THIS IS WHERE THE USER INTERRUPT HANDLER RESIDES . . .
1472: 
1473: INTRUN:
1474:         SETZM INTREQ(PID)
1475:         SETZM AC1
1476:         EXCH AC1,APRIN3(PID)
1477:         JUMPE AC1,INTR6
1478:         MOVEM AC1,USRPC(PID)    ; GET RIGHT USRPC (INSTEAD OF JOBTM5)
1479: INTR6:  PUSH P,LASTPR(PID)      ; WE WILL RESET PR FROM THIS
1480:         PUSH P,USRSAV(PID)      ; WE MIGHT HAVE INTERRUPTED UUOCON BEFORE IT IS REENTRANT, SO SAVE ALL THIS STUFF . . .
1481:         PUSH P,UUO0(PID)        ; THE UUO LOCATION
1482:         PUSH P,@UUOLOC(PID)     ; THE UUO ITSELF
1483: IFN FTXCTR,<PUSH P,160
1484:             PUSH P,@161>        ; FOR XCTR SIMULATOR
1485:         MOVE AC1,JOB(PID)
1486:         MOVEM AC1,SJOB(PID)     ; NOW SAVE AWAY THE JOB NUMBER WHERE WE CAN FIND IT AGAIN REDILY
1487:         PUSH P,@CLKCH(PID)      ; WE MUST ALSO SAVE AWAY CLKINT'S DATA BECAUSE IT IS NOT REENTRANT
1488:         PUSH P,CLKS17(PID)      ; IT DEPENDS ON THIS STAYING CONSTANT TOO!
1489:         PUSH P,JOBDAT(PID)      ; THESE ARE FOR THE REENTRANT PART OF UUOCON. FIRST THE JOB ADDRESS
1490:         PUSH P,USRREL(PID)      ; NEXT THE HIGHEST LOCATION IN THE LOSER'S CORE
1491:         PUSH P,SCHEDF(PID)      ; WE MUST SAVE THIS BECAUSE WE MIGHT HAVE INTERRUPTED WSCHED
1492:         PUSH P,APRPC(PID)       ; SAVE ANY APR ERRORS THAT MAY BE, BECAUSE THE I-LEVEL PROCESS MAY MAKE ITS OWN
1493:         PUSH P,APRERR(PID)
1494:         PUSH P,APRIN1(PID)
1495:         MOVEI AC1,1(P)          ; SAVE USER CHANNEL TABLE TOO
1496:         HRLI AC1,USRPRT(PID)
1497:         MOVEI AC2,(AC1)
1498:         ADDI AC2,USRJDA+17-USRPRT
1499:         BLT AC1,(AC2)
1500:         ADD P,[XWD USRJDA+20-USRPRT,USRJDA+20-USRPRT]
1501:         SETOM INTACT(PID)       ; WE ARE NOW AT INTERRUPT LEVEL
1502:         MOVEI J,JOBN-1
1503: INTR2:  SKIPN AC1,JBTIRQ(J)     ; INTERRUPT WAITING HERE?
1504: INTR1:  SOJG J,.-1              ; NO
1505:         JUMPE J,INTXIT          ; IF NONE AT ALL, GO AWAY
1506:         PUSHJ P,GETINT          ; GET THE BIT CORRESPONDING TO THE INTERRUPT
1507:         JRST INTR1              ; ALL MASKED OUT, LOOP BACK FOR NEXT GUY
1508:         MOVE AC2,JBTSTS(J)
1509:         TLNN AC1,INTSWW!INTSHW  ; IF THIS IS A SHUFFLE OR A SWAP INTERRUPT, THE JOB IS REALLY THERE!
1510:         TLNN AC2,SWP!SHF
1511:         SKIPN PROG,JBTADR(J)    ; IS THIS JOB REALLY HERE?
1512:         JRST INTSWAPIN          ; I GUESS NOT. HAVE HIM SWAPPED IN IF HE IS SWAPPED OUT.
1513:         LDB AC3,PSEGN           ; DOES HE HAVE AN UPPER?
1514:         JUMPE AC3,INTR11
1515:         MOVE AC2,JBTSTS(AC3)    ; SEE IF IT IS IN CORE
1516:         TLNN AC1,INTSWW!INTSHW
1517:         TLNN AC2,SWP!SHF
1518:         SKIPN JBTADR(AC3)
1519:         JRST INTSWS             ; SWAP SEGMENT IN
1520: INTR11: SKIPE JBTIIP(J)         ; IS THIS JOB ALREADY AT I-LEVEL?
1521:         JRST [  SETOM INTREQ(PID)
1522:                 JRST INTR1]
1523: INTR9:  MOVE AC1,JBTIRQ(J)      ; PICK UP INTERRUPT BITS AGAIN
1524:         PUSHJ P,GETINT          ; GET BIT CORRESPONDING TO INTERRUPT
1525:         JRST INTR1              ; ALL MASKED OUT
1526:         JRST INTR7              ; GOT IT. GO SERVICE INTERRUPT
    CLKSER page# 0031 next  prev
1528: ; ROUTINE TO GET FIRST SERVICABLE INTERRUPT BIT FROM WORD OF BITS
1529: ; ENTER WITH COPY OF JBTIRQ IN AC1
1530: ; WILL RETURN SINGLE SERVICABLE BIT IN AC1
1531: 
1532: GETINT: MOVSI AC2,INTWAIT
1533:         TDNE AC2,JBTIEN(J)
1534:         JRST GTINT1             ; HERE IF TRYING TO FINISH UUO (VIA UWAIT)
1535:         MOVEI AC3,
1536: INTR8:  JFFO AC1,.+1            ; PICK OFF FIRST BIT. SERVE INTERRUPTS ONLY ONE AT A TIME.
1537:         MOVNS AC2
1538:         MOVSI AC1,(1B0)
1539:         LSH AC1,(AC2)           ; AC1 NOW CONTAINS ONLY ONE BIT AND IT IS IN THE POSITION OF THE FIRST BIT IN JBTIRQ(J)
1540:         TDNE AC1,JBTMSK(J)      ; SEE IF THIS PROCESSOR IS ENABLED FOR THIS INTERRUPT
1541:         JRST CPOPJ1
1542:         IORB AC1,AC3
1543:         ANDCA AC1,JBTIRQ(J)     ; ARE THERE ANY MORE INTERRUPTS PENDING?
1544:         JUMPE AC1,CPOPJ         ; NO, GO ON TO NEXT GUY
1545:         JRST INTR8              ; YES
1546: 
1547: GTINT1: TDNN AC2,AC1            ; SKIP IF INTWAIT ENABLED AND REQUESTED
1548:         POPJ P,                 ; ENABLED BUT NOT REQUESTED YET
1549:         MOVE AC1,AC2
1550:         JRST CPOPJ1             ; DO INTWAIT INT FIRST
    CLKSER page# 0032 next  prev
1552: ; HERE WE CLEAR THE INTERRUPT BIT IN JBTIRQ AND ACTUALLY
1553: ; START UP THE INTERRUPT PROCESS
1554: 
1555: INTR7:  TDNN AC1,JBTIRQ(J)
1556:         JRST INTR9              ; SOMEONE ATE THE INTERRUPT FROM UNDER US
1557:         ANDCAM AC1,JBTIRQ(J)    ; WE HAVE SERVICED THIS INTERRUPT SO FORGET IT.
1558:         TDNN AC1,JBTIEN(J)      ; IS THIS GUY ENABLED FOR THIS INTERRUPT?
1559:         JRST INTR2              ; NO, FORGET IT.
1560:         SKIPN JBTIIP(J)
1561:         JRST INTR14
1562:         IORM AC1,JBTIRQ(J)
1563:         SETOM INTREQ(PID)
1564:         JRST INTR2              ; TRY TO GET BACK NEXT TICK
1565: INTR14: IORM AC1,JBTIIP(J)      ; YES, HE NOW HAS THIS INTERRUPT IN PROGRESS
1566:         HLRZ TAC,PROG
1567:         SKIPN AC3,JOBINT(PROG)  ;DOES HE WANT INTS SOMEWHERE ELSE?
1568:         JRST INT14A             ;NO
1569:         ADDI AC3,2              ;THIS MUST BE LEGAL, TOO
1570:         CAIL AC3,JOBPFI+2
1571:         CAILE AC3,(TAC)
1572:         JRST INTADC             ;SHIT ON HIM (MUST BE IN LOWER)
1573:         ADDI AC3,(PROG)
1574:         SKIPA AC2,AC3           ;THE BITS GO HERE-2
1575: INT14A: MOVEI AC2,JOBCNI+2(PROG);OR HERE
1576:         MOVEM AC1,-2(AC2)       ; PUT HIS INTERRUPT BITS WHERE HE CAN FIND THEM
1577:         SKIPN AC2,AC3
1578:         MOVEI AC2,JOBAPR(PROG)
1579:         HRRZ AC2,(AC2)          ; PICK UP HIS TRAP ROUTINE ADDRESS
1580:         CAIL AC2,JOBPFI
1581:         CAILE AC2,(TAC)
1582:         CAIA
1583:         JRST INTR10
1584:         LDB AC1,PSEGN           ; SEE IF PC IS IN UPPER
1585:         JUMPE AC1,INTADC        ; NO UPPER, ERROR
1586:         HLRZ AC1,JBTADR(AC1)
1587:         ADDI AC1,400000
1588:         CAIL AC2,400000
1589:         CAMLE AC2,AC1
1590:         JRST INTADC             ; OUT OF UPPER, ADDRESS CHECK
    CLKSER page# 0033 next  prev
1592: ; HERE WE INITIALIZE ALL THE SYSTEM VARIABLES IN PREPARATION FOR RUNNING THE USER INTERRUPT PROCESS
1593: 
1594: INTR10: PUSH P,UUOPC(J)         ; SAVE HIS UUO LEVEL PC TOO
1595:         MOVEM PROG,JOBDAT(PID)  ; SET UP ADDRESS OF USER AREA FOR UUOCON.
1596:         HLRZM PROG,USRREL(PID)  ; UUOCON NEEDS JOBDAT, USRREL, AND JOB, AND THAT'S ALL
1597:         MOVEM J,JOB(PID)        ; THIS IS OUR TEMPORARY JOB NUMBER
1598:         CAME J,SJOB(PID)        ;MIGHT ALREADY BE THERE
1599:         PUSHJ P,U2S             ; PICK UP JOBJDA
1600:         SETZM APRERR(PID)       ; CLEAR OUT THIS BECAUSE PREVIOUS JOB MAY HAVE HAD AN ERROR
1601:         SETZM APRPC(PID)
1602:         SETZM APRIN1(PID)
1603:         SETZM SCHEDF(PID)
1604:         SETOM STIME(J)          ; MARK CORE IMAGE AS ALTERED NOW.
1605:         LDB AC1,PSEGN           ; SEE IF WE MUST MARK UPPER
1606:         JUMPE AC1,INTR5         ; NONE THERE.
1607:         MOVE AC2,JBTSTS(AC1)    ; DON'T MARK CORE IMAGE DIRTY IF WRITE PROTECTED
1608:         TLNN AC2,JWP
1609:         SETOM STIME(AC1)
1610: INTR5:  MOVNI AC1,10
1611:         MOVEM AC1,INTQUANT(PID) ; HE GETS 8 TICKS BEFORE DOOM STRIKES
1612:         MOVEI AC1,INTCH7
1613:         MOVEM AC1,INTDISP(PID)  ; COUNT DOWN HIS QUANTUM TIME EVERY CLOCK BREAK
1614:         MOVM AC1,JOBQUE(J)      ; SEE IF HE IS WAITING FOR AN INTERRUPT
1615:         CAIE AC1,INTWQ
1616:         JRST INTWRJ
1617:         MOVE AC1,JBTIIP(J)      ; DO WE WAKE HIM UP?
1618:         TDNN AC1,JBTWKM(J)
1619:         JRST INTWRJ             ; NO
1620:         MOVNI AC1,TQ            ; YES, WAKE HIM UP WITH HIGH PRIORITY
1621:         MOVEM AC1,JOBQUE(J)
1622:         PUSHJ P,REQUE
1623: INTWRJ: PUSHJ P,GETPR           ; SET UP PROTECTION-RELOCATION
1624:         DATAO APR,TAC
1625:         MOVEM P,INTSP(PID)      ; ALL WE NEED TO SAVE IS THE STACK POINTERS.
1626:                                 ; CLKINT DOESN'T DEPEND ON ACCUMULATORS.
1627:         MOVE AC2,JBTIIP(J)
1628:         TLNN AC2,INTWAIT        ; IF WE ARE TRYING TO DEBREAK,
1629:                                 ; MUST GIVE HIM HIS UUO-LEVEL ACCUMULATORS
1630:         JRST INTR4
1631:         ANDCAM AC2,JBTIEN(J)    ; HE IS NO LONGER ENABLED FOR INTERRUPT-WAIT
1632:         SKIPN AC2,AC3
1633:         MOVEI AC2,JOBTPC+1(PROG)
1634:         MOVE AC1,USRPC(PID)     ; GIVE HIM HIS MOST ACCURATE PC
1635:         MOVEM AC1,-1(AC2)
1636:         MOVSI 17,JOBDAC(PROG)   ; GIVE HIM HIS UUO-LEVEL ACCUMULATORS TO SAVE AWAY
1637:         MOVE AC1,JBTUPC(J)      ; AND RESTART HIM JUST AFTER THE UWAIT UUO
1638:         MOVEM AC1,UUO0(PID)
1639:         JUMPE PID,INTR15
1640:         BLT 17,17
1641:         JRST 13,@UUO0+P2PID
1642: INTR15: BLT 17,17
1643:         JRST 13,@UUO0+P1PID
    CLKSER page# 0034 next  prev
1645: ; HERE, HE IS NOT CONTINUING AFTER A UWAIT, BUT IS BEING RUN REGULARLY
1646: 
1647: INTR4:  MOVSI AC1,JOBAC(PROG)
1648:         HRRI AC1,INTACS(PID)    ; SAVE HIS UUO-LEVEL ACCUMULATORS, FOR HE WILL DO UUO'S
1649:         BLT AC1,INTACS+17(PID)
1650:         MOVE AC1,USRPC(PID)     ;SHOULD BE HERE BY NOW
1651:         TLNE AC1,USRMOD
1652:         JRST INTR4A
1653:         MOVE AC1,UUOPC(J)       ; IF IN EXEC, GIVE HIM HIS LAST UUO-LEVEL PC.
1654:         CAIN AC1,USRXT5
1655:         MOVE AC1,UUO0(PID)      ;WHICH MAY BE HERE IF WE INTERRUPTED UUOCON EARLY
1656:         TLZN AC1,USRMOD         ;FLAG IT AS COMING FROM EXEC
1657:         TDZA AC1,AC1            ;OR RET ZERO IF WE DON'T KNOW IT (RECURSION CONFUSION)
1658:         SUBI AC1,1              ;ADJUST IT TO POINT AT HIS UUO
1659: INTR4A: SKIPE AC2,AC3
1660:         JRST .+3
1661:         MOVEI AC2,JOBTPC+1(PROG)
1662:         MOVEI AC3,JOBAPR(PROG)
1663:         MOVE AC3,(AC3)
1664:         MOVEM AC1,-1(AC2)
1665:         MOVE AC2,JBTPRV(J)
1666:         TLNN AC2,LUPPRV
1667:         TLZ AC3,4000            ;DON'T SET IOT USER UNLESS LOCAL
1668:         MOVE 16,J               ; NOW SET UP HIS ACCUMULATORS
1669:         MOVE 2,PROG
1670:         MOVE 1,SPWBUT
1671:         SETZM 3
1672:         MOVE 15,JBTIIP(16)
1673:         TLNE 15,INTSHW!INTSWW
1674:         SETOM 3                 ; IF HE IS ABOUT TO GET SHUFFLED OR SWAPPED, TELL HIM
1675:         MOVEI 4,1
1676:         SKIPE PID
1677:         MOVEI 4,2               ; PROCESSOR NUMBER IN 4
1678:         SETZM 5                 ; 5 TELLS WHETHER THE OTHER PROCESSOR IS ALIVE
1679:         MOVE 6,JBTSTS(16)       ; HE WANTS HIS STATUS WORD IN 6 TOO
1680:         LDB 7,[POINT 6,JBTSTS(16),35]
1681:         HLRZ 7,JBTADR(7)
1682:         MOVE 10,INTDTM(16)
1683:         MOVM 14,JOBQUE(16)      ;TELL HIM HIS CURRENT Q
1684:         SKIPN P2NUM
1685:         JRST SIXDED
1686:         CAIE 4,1
1687:         JRST SIXTST
1688:         SKIPGE PALIVE+P2PID
1689:         SETOM 5
1690:         JRST 13,(AC3)           ;AC3 HAD BETTER THE HELL NOT BE CLOBBERED BY SHIT ABOVE
1691: SIXTST: SKIPGE PALIVE+P1PID
1692: SIXDED: SETOM 5
1693:         TLZ AC3,37      ;AVOID @ LOOPS
1694:         JRST 13,@AC3    ;SINCE JRST 2,() DOESN'T WORK ON 6
    CLKSER page# 0035 next  prev
1696: ; ROUTINE TO TYPE OUT ERROR MESSAGE FOR ILL. STARTING ADDRESS
1697: 
1698: INTADC: SETZM JBTIIP(J)         ; IF ADDRESS CHECK, GET HIM OUT OF INTERRUPT LEVEL
1699:         PUSHJ P,TTYERP          ; NOW GIVE HIM A NASTY MESSAGE
1700:         PUSHJ P,INLMES
1701: ASCIZ /INTERRUPT ADDRESS OUT OF BOUNDS
1702: /
1703:         PUSHJ P,HOLD            ;PRINT ↑C CRLF . CRLF.  CALL TTYSTC AND ESTOP
1704:         JRST INTR1
1705: 
1706: INTXIT: JRST 2,@[.+1]
1707:         SETZM INTACT(PID)       ; ALL DONE. RESTORE ALL THE STUFF WE SAVED UP FRONT.
1708:         SETZM INTDISP(PID)
1709:         HRLI AC1,-USRJDA-20+USRPRT+1(P)
1710:         HRRI AC1,USRPRT(PID)
1711:         BLT AC1,USRJDA+17(PID)
1712:         SUB P,[XWD USRJDA+20-USRPRT,USRJDA+20-USRPRT]
1713:         POP P,APRIN1(PID)
1714:         POP P,APRERR(PID)
1715:         POP P,APRPC(PID)
1716:         POP P,SCHEDF(PID)
1717:         POP P,USRREL(PID)
1718:         POP P,JOBDAT(PID)
1719:         POP P,CLKS17(PID)
1720:         POP P,@CLKCH(PID)
1721: IFN FTXCTR,<POP P,@161
1722:             POP P,160>          ; FOR XCTR SIMULATION
1723:         POP P,@UUOLOC(PID)
1724:         POP P,UUO0(PID)
1725:         POP P,USRSAV(PID)
1726:         POP P,LASTPR(PID)       ; RESTORE PR
1727:         MOVE J,SJOB(PID)
1728:         MOVEM J,JOB(PID)
1729:         DATAO APR,LASTPR(PID)   ; RESTORE JOB'S PROTECTION-RELOCATION
1730:         POPJ P,
    CLKSER page# 0036 next  prev
1732: ; ROUTINE TO SWAP A GUY IN SO HE MAY BE INTERRUPTED
1733: 
1734: INTSWAPIN:
1735:         MOVE AC3,J              ; AC3 IS JOB TO TEST FOR BEING IN
1736:         PUSHJ P,INTSWT          ; SWAPIN TEST SUBR
1737:         JRST INTR1              ; NO CAN DO
1738:         LDB AC3,PSEGN           ; GET SEGMENT #
1739:         JUMPE AC3,INTR1
1740:         MOVE TAC,JBTSTS(AC3)
1741:         TLNE TAC,SWP            ; IF SWAPPED OUT,
1742:         JRST INTR1              ; NORMAL THING WILL HAPPEN
1743:         MOVSI TAC,JHLDIN        ; ELSE HOLD IT IN
1744:         IORM TAC,JBTSTS(AC3)    ; FOR LOWER
1745:         JRST INTR1
1746: 
1747: INTSWS: PUSHJ P,INTSWT          ; AC3 JOB TO BRING IN, J LOWER
1748:         JRST INTR1
1749:         MOVE TAC,JBTSTS(J)
1750:         TLNE TAC,SWP            ; IF LOWER IS SWAPPED OUT,
1751:         JRST INTR1              ; LET NORMAL THING HAPPEN
1752:         MOVSI TAC,JHLDIN
1753:         IORM TAC,JBTSTS(J)      ; ELSE HOLD HIM IN FOR UPPER
1754:         JRST INTR1
1755: 
1756: INTSWT:                         ; SEE IF HE IS MASKED OUT
1757:         TDNN AC1,JBTMSK(J)      ; ARE ANY OF THOSE BITS ON?
1758:         POPJ P,                 ; APPARANTLY NOT, DON'T BOTHER TO CALL HIM IN
1759:         SETOM INTREQ(PID)       ; COME BACK NEXT TIME AROUND TOO
1760:         MOVE AC2,JBTSTS(AC3)
1761:         TLNN AC2,SWP            ; NEED TO GET HIM IN CORE?
1762:         POPJ P,                 ; NO, MUST BE SHUFFLE, JUST WAIT
1763:         EXCH AC3,J              ; GET US IN J
1764:         MOVSI TAC,INTSNB
1765:         PUSHJ P,SETSIN          ; PUT INTO SWAP IN LIST
1766:         EXCH AC3,J
1767:         JRST CPOPJ1
    CLKSER page# 0037 next  prev
1769: ; WE COME BACK TO HERE AFTER AN INTERRUPT - INTCH7,INTDSM,INTOUT,INTERR
1770: ; NOW WE HAVE TO FIGURE OUT HOW WE GOT HERE AND WHAT TO DO ABOUT IT
1771: 
1772: INTCH7: SKIPE APRERR(17)        ; THIS IS THE PLACE WE COME UPON CH7 BREAKS WHILE AN I-LEVEL PROCESS IS RUNNING. FIRST CHECK FOR APR ERRORS
1773:         JRST INTAPR
1774:         SKIPE SCHEDF(17)        ; SEE IF THE BOOB HAS GOT HIMSELF IN IO WAIT
1775:         JRST INTERP             ;MAY HAVE BEEN FROM ESTOP, SO CHECK JERR
1776:         AOSL INTQUANT(17)       ; OR MAYBE HIS TIME HAS EXPIRED
1777:         JRST INTOUT             ; YES
1778:         JUMPE 17,INTOK
1779:         MOVE 17,CLKS17+P2PID
1780:         JEN @CL2CHL
1781: INTOK:  MOVE 17,CLKS17+P1PID
1782:         JEN @CLKCHL
1783: INTOUT: JSR @CLKESV(17)         ;SETS UP J, PROG, P, DOES S2U SOMETIMES, ETC.
1784:         PUSHJ P,TTYERP
1785:         PUSHJ P,INLMES
1786: ASCIZ /?
1787: I-LEVEL TIME-OUT/
1788:         MOVE TAC1,@CLKCH(PID)
1789: INTERR: PUSHJ P,PCP
1790:         PUSHJ P,PRCRCC
1791:         PUSHJ P,TTYSTC
1792:         PUSHJ P,ESTOP
1793: INTDSM: SETZM ESTINT
1794:         MOVE P,INTSP(PID)       ; HERE WE ARE AT THE DISMIS UUO
1795:         MOVE J,JOB(PID)         ; PICK UP ALL THE ACCUMULATORS
1796:         MOVE PROG,JOBDAT(PID)
1797:         POP P,UUOPC(J)
1798:         MOVEI AC1,JOBAC(PROG)
1799:         HRLI AC1,INTACS(PID)    ; PUT BACK EVERYTHING
1800:         BLT AC1,JOBAC+17(PROG)
1801:         CAME J,SJOB(PID)        ;DON'T BOTHER IF ALREADY OK
1802:         PUSHJ P,S2U             ; MOVE JOBJDA BACK
1803:         SETZM JBTIIP(J)         ; GET HIM OUT OF INTERRUPT LEVEL
1804:         JRST INTR2
    CLKSER page# 0038 next  prev
1806: ; WE GET HERE FROM A DEBREAK UUO - INTDEB, INTERP, INTAPR
1807: 
1808: INTDEB: MOVE P,INTSP(PID)
1809:         MOVE J,JOB(PID)
1810:         MOVE PROG,JOBDAT(PID)
1811:         MOVE AC1,UUOPC(J)       ;ADDRESS OF WHERE WE WANT TO BE AT MAIN LEVEL
1812:         MOVEM AC1,USRPC(PID)
1813:         CAMN J,SJOB(PID)
1814:         MOVEM AC1,-USRJDA-20+USRPC(P)   ;THIS IS WHAT WILL BE PUT INTO USRPC!!
1815:         HRLI AC1,JOBAC(PROG)
1816:         HRRI AC1,JOBDAC(PROG)
1817:         HRRI AC2,17(AC1)
1818:         BLT AC1,(AC2)           ;REAL ACS WILL BE UUO ACS AT TIME OF DEBREAK UUO
1819:         MOVM AC1,JOBQUE(J)
1820:         CAIE AC1,IOWQ
1821:         JRST INTDB1
1822:         MOVNI AC2,RUNQ          ;IN CASE WE ARE FAILING TO GO BACK TO A UUO IN IOWQ
1823:         MOVEM AC2,JOBQUE(J)
1824:         PUSHJ P,REQUE           ;(THIS USED TO BE INLINE CODE - REG)
1825: INTDB1: CAME J,SJOB(PID)        ;NOT NECESSARY IF CURRENT JOB
1826:         PUSHJ P,S2U
1827:         POP P,UUOPC(J)
1828:         SETZM JBTIIP(J)
1829:         JRST INTR2
1830: 
1831: INTERP: JSR @CLKESV(17)
1832:         SKIPE ESTINT
1833:         JRST INTDSM             ;GOT HERE FROM ESTOP
1834:         PUSHJ P,TTYERP
1835:         PUSHJ P,INLMES
1836: ASCIZ /?
1837: ATTEMPT TO SCHEDULE I-LEVEL PROCESS, UUO/
1838:         MOVE TAC1,UUOPC(J)
1839:         SOJA TAC1,INTERR
1840: 
1841: INTAPR: JSR @CLKESV(17)
1842:         PUSHJ P,TTYERP
1843:         PUSHJ P,INLMES
1844: ASCIZ /?
1845: USER I-LEVEL /
1846:         MOVEI TAC,[ASCIZ /CH3 ERROR/]
1847:         MOVE AC1,APRERR(PID)
1848:         TRNE AC1,ILM
1849:         MOVEI TAC,[ASCIZ /ILL. MEM. REF./]
1850:         TRNE AC1,NXM
1851:         MOVEI TAC,[ASCIZ /NON-EX. MEM./]
1852:         TRNE AC1,POV
1853:         MOVEI TAC,[ASCIZ /PDL OV/]
1854:         PUSHJ P,CONMES
1855:         MOVE TAC1,APRPC(PID)
1856:         JRST INTERR
    CLKSER page# 0039 next  prev
1858: ;INTKILL  ROUTINE TO CLEAR A JOB'S INTERRUPT ENABLINGS AND RESET HIS MASKS
1859: 
1860: INTKILL:
1861:         PUSH P,AC1
1862:         PUSH P,AC2
1863:         SETZM JBTIEN(J)         ; CLEAR THE ENABLE BITS FIRST
1864:         SETZM JBTIRQ(J)         ; NOW CLEAR ANY PENDING INTERRUPTS
1865:         SETZM JBTIIP(J)
1866:         SETOM JBTWKM(J)         ; INITIALIZE THE WAKE UP MASK
1867:         SETOM JBTMSK(J)         ; NOW CLEAR THE PROCESSOR MASK
1868:         PUSHJ P,APRDKL          ;FLUSH CLOCK REQUESTS
1869:         POP P,AC2
1870:         POP P,AC1
1871:         SETZM UUOPTR(J)         ;ALSO DISABLE UUO INTERPRETER
1872:         POPJ P,
    CLKSER page# 0040 next  prev
1874: ;INIJOB         ROUTINE TO INITIALIZE A JOB SLOT
1875: ;CALL AT CLOCK LEVEL OR UUO LEVEL
1876: ;       PUSHJ   P,INIJOB
1877: ;       <JOB CAPACITY EXCEEDED>
1878: ;       <CANNOT GET FREE STORAGE - TRY AGAIN LATER>
1879: ;       <SUCCESS. J IS SET UP; PROG IS ZERO, JDAT IS ZERO>
1880: ;       IF YOU WANT TO MAKE THIS A REAL JOB, YOU MUST CLAIM JOB
1881: ;       SLOT BY MARKING JNA OR CMWB IN JBTSTS.
1882: 
1883: ;CLOBBERS TAC
1884: ;SETS UP: JBTADR,JBTPRV,JBTBTM,JBTSTS,TTIME,RTIME,JBTUFD,DSKPPN,JBTRNB,JBTPR2,
1885: ;         JBTKCJ,J
1886: 
1887: INIJB0: MOVSI   TAC,JNA!CMWB
1888: INIJB1: MOVEI   J,1                     ;SEEK JOB SLOT
1889: INIJB2: TDNN    TAC,JBTSTS(J)
1890:         JRST    CPOPJ1                  ;THIS ONE IS FREE.
1891:         CAMGE   J,JOBNM1                ;HAVE WE REACHED MAXIMUM SLOT NUMBER?
1892:         AOJA    J,INIJB2                ;NOT YET.
1893:         MOVEI   J,0                     ;RETURN A ZERO
1894:         POPJ    P,                      ;AND LOSE.
1895: 
1896: INIJOB:
1897:         JUMPN   PID,CPOPJ               ;GOD FORBID THE PDP-6 SHOULD TRY THIS
1898:         PUSHJ   P,INIJB0                ;SEEK A JOB SLOT
1899:         POPJ    P,                      ;NONE AVAILABLE
1900:         SKIPE   JBTADR(J)               ;MAKE SURE THERE'S NO CORE  FOR THIS JOB
1901:         PUSHJ   P,INIJXX                ;COMPLAIN
1902:         SKIPE   JBTPDL(J)               ;DO WE HAVE A PDL YET?
1903:         JRST    INIJB4
1904:         PUSH    P,AC3
1905:         PUSH    P,AC1
1906:         PUSHJ   P,MAKPDL
1907:         JRST    INIJB5                  ;HERE IF NO FREE STORAGE.
1908:         MOVSI   TAC,JNA!CMWB            ;IS THIS JOB SLOT STILL THERE?
1909:         TDNN    TAC,JBTSTS(J)
1910:         JRST    INIJB3                  ;YES. THIS SLOT IS STILL THERE.
1911:         PUSHJ   P,INIJB1                ;SEEK A NEW SLOT.
1912:         JRST    INIJB6                  ;NO SLOTS
1913: INIJB3: MOVEM   AC1,JBTPDL(J)           ;SET JOB PDL.
1914:         POP     P,AC1
1915:         POP     P,AC3
1916: INIJB4: SETZB   PROG,TTIME(J)           ;NO CORE ANYWHERE.
1917:         SETZB   JDAT,RTIME(J)
1918:         SETZM   DSKOPS(J)               ;NO DISK USAGE YET
1919:         SETZM   JBTWAT(J)               ;HAVEN'T WAITED FOR SYSTEM YET
1920:         SETZM   JB2WAT(J)               ;DITTO
1921:         SETZM   XTIME(J)                ;MAKE SURE NO-UPDATE BIT IS CLEAR IN XTIME
1922:         MOVSI   TAC,JERR
1923:         MOVEM   TAC,JBTSTS(J)           ;AN NICE WAY TO START: JERR.
1924:         SETZM   JBTADR(J)               ;NO CORE.
1925:         SETZM   JBTPRV(J)               ;NO ACTIVE PRIVILEGES
1926:         SETZM   JB2PRV(J)               ;OR PASSIVE ONES
1927:         SETZM   JBTRNB(J)
1928:         SETZM   JBTPR2(J)               ;NO PEEK-POKE
1929: IFN FTDISK,<
1930:         SETZM   JBTUFD(J)               ;NO UFD ADDRESS
1931: IFN FTDSKPPN,<
1932:         SETZM   DSKPPN(J)               ;NO DSKPPN
1933: >>
1934:         SETZM   JBTKCJ(J)               ;NO KILO-CORE JIFFIES
1935:         MOVE    TAC,TIMDAT              ;GET <DATE>,,<TIME IN SECS>
1936:         MOVEM   TAC,JBTBTM(J)           ;SAVE JOB BEGINING TIME.
1937:         MOVEM   TAC,FTIME(J)            ;SET TIME LAST RUN.
1938:         JRST    CPOPJ2                  ;GIVES THE (DOUBLE) SKIP RETURN.
1939: 
1940: INIJB6: MOVEI   AC1,1(AC1)              ;SET UP RIGHT ADDRESS FOR FSGIVE.
1941:         PUSHJ   P,FSGIVE
1942:         SOS     (P)                     ;NO JOBS RETURN # 0
1943: INIJB5: POP     P,AC1                   ;NO FREE STORAGE
1944:         POP     P,AC3
1945:         JRST    CPOPJ1                  ;NO F.S.  RETURN # 1
1946: 
1947: ;HERE TO RELEASE AN ILL-GOTTEN JOB.
1948: RELJOB: JUMPN   PID,CPOPJ               ;GOD FORBID THE PDP-6 SHOULD EVER TRY
1949:         MOVEI   AC1,0
1950:         EXCH    AC1,JBTPDL(J)
1951:         MOVSI   TAC,JNA 
1952:         ANDCAM  TAC,JBTSTS(J)
1953:         JUMPE   AC1,CPOPJ
1954:         MOVEI   AC1,1(AC1)
1955:         JRST    FSGIVE
1956: 
1957: MAKPDL:                                ;ALSO CALLED BY SYSINI
1958:         MOVEI   AC3,JBTPLN              ;GET A PDL FOR THIS JOB.
1959:         PUSHJ   P,FSGET                 ;FROM FREE STORAGE.
1960:         POPJ    P,                      ;NO FREE STORAGE.
1961:         HRLI    AC1,1-<JBTPLN+JOBPRT-JOBPFI>    ;SET LEFT SIDE TO COUNT.
1962:         SETZM   (AC1)                   ;ZERO FIRST LOCATION OF PDL
1963:         MOVSI   AC3,(AC1)               ;SOURCE OF BLT
1964:         HRRI    AC3,1(AC1)              ;DESTINATION
1965:         BLT     AC3,JBTPLN-1(AC1)       ;ZERO THE ENTIRE PDL.
1966:         SOJA    AC1,CPOPJ1              ;AC1 SET AS PDL POINTER. SKIP RETURN.
1967: 
1968: INIJXX: PUSHACS
1969:         PUSHJ   P,DISMES
1970:         ASCIZ   /JBTADR NOT ZERO AT INIJOB (OR ESTSG2) /
1971:         PUSHJ   P,DISJOB
1972:         PUSHJ   P,DISTAB
1973:         MOVE    TAC,JBTADR(J)
1974:         PUSHJ   P,DISOCT
1975:         PUSHJ   P,DISCRLF
1976:         POPACS
1977:         DEBCHECK
1978:         POPJ    P,
    CLKSER page# 0041 next  prev
1980: SUBTTL  COMCON  4 AUG 67         THE COMMAND DECODER
1981: 
1982: ;CALLED FROM CLOCK ROUTINE WHEN 'COMCNT' IS GREATER THAN 0
1983: ;AS SET BY TTY SERVICE ROUTINE
1984: ;ALL AC'S HAVE BEEN SAVED BY CLOCK CHANNEL
1985: ;THE COMMAND DECODER CALLS TTYCOM WHICH SCANS FOR TTY WHICH TYPED
1986: ;THE COMMAND AND THEN DISPATCHES(PUSHJ) TO APPROPRIATE
1987: ;COMMAND SETUP ROUTINE OF THE SAME NAME WITH AC'S SET AS:
1988: ;ITEM = JOB NUMBER
1989: ;TAC = BYTE POINTER TO COMMAND STRING(SPACE OR CR AFTER COMMAND NAME)
1990: ;DAT = BYTE POINTER TO LAST OUTPUT CHARACTER
1991: ;DEVDAT = ADDRESS OF DEVICE DATA BLOCK TYPING COMMAND
1992: ;JDAT = ADDRESS OF JOB AREA, = 0 IF NO JOB AREA
1993: ;PROG = ADDRESS OF PROGRAM AREA, 0 MEANS NOT IN CORE OR NO CORE
1994: ;IOS IS SET TO 0, USED FOR ADDRESS OF SUBSEQUENT CALLS
1995: ;DEVDAT IS ALSO PUSHED ON END OF PD LIST SO IT MAY BE DESTROYED.
1996: ;UPON RETURN FROM COMMAND SETUP ROUTINE, A CR-LF IS ADDED TO
1997: ;MESSAGE AND TTY IS STARTED ON TTY SPECIFIED BY -1(PDP)
1998: ;SEVERAL COMMAND FLAGS ARE CHECKED BEFORE DISPATCHING TO
1999: ;COMMAND SETUP ROUTINES TO SEE IF COMMAND IS LEGAL AT THIS TIME
2000: ;SEVERAL MORE FLAGS ARE CHECKED UPON RETURN FROM COMMAND SETUP
2001: ;ROUTINES(UNLESS AN ERROR HAS OCCURRED) FOR STANDARD
2002: ;COMMAND RESPONSE
2003: ;IF AN ERROR OCCURS, THE JOB NO.(ITEM) SHOULD BE 0 ON RETURN
2004: ;SO THAT JOB WILL NOT BE INITIALIZED IF FIRST COMMAND.
2005: ;ERRMES ROUTINE WILL SET ITEM TO 0
2006: 
2007: ;SINCE THE COMMAND DECODER IS CALLED FROM THE CLOCK ROUTINE
2008: ;COMMAND SETUP ROUTINE MUST RUN TO COMPLETION QUICKLY
2009: ;IF A COMMAND FUNCTION CANNOT DO THIS, IT MUST JUST SET
2010: ;THE JOB TO RUNABLE STATUS AND RETURN IMMEDIATELY
2011: ;OR DELAY THE COMMAND FOR LATER EXECUTION
    CLKSER page# 0042 next  prev
2013: ;COMMAND
2014: 
2015: ;       HERE IF TTYCOM DIDN'T FIND ANYONE
2016: NOCOMS:
2017: IFN FTTTYBUG,<
2018:         AOSG    LINSV1          ;SKIP IF WE FAILED TO FIND A COMMAND TWICE
2019:         POPJ    P,              ;NO THIS IS OUR FIRST LOST COMMAND
2020:         JRST    CNTCOM
2021: ;>      POPJ    P,              ;THIS IS A NO-OP IF THERE ARE NO COMMANDS
2022: 
2023: COMMAND:
2024:         PUSHJ   P,TTYCOM        ;SETUP DEVDAT,DAT,TAC,AND ITEM
2025:                                 ;FOR ANY TTY WHICH HAS TYPED A COMMAND
2026:         JRST    NOCOMS          ;THERE WERE NO TTY'S WITH COMMANDS
2027:         SETOM   LINSV1          ;MARK THAT WE SAW A COMMAND
2028: COM0:   PUSH    P,DDB           ;SAVE TTY DEVICE DATA BLOCK ADDRESS
2029:         PUSHJ   P,CTEXT         ;SCAN COMMAND NAME, RETURN IT IN TAC1
2030:         CAMN    TAC1,['HAL   '] ;LET ↑C THROUGH
2031:         JRST    NOSCRU
2032:         JUMPE   J,NOSCRU
2033:         MOVE    AC1,JBTSTS(J)
2034:         TLNN    AC1,JLOG
2035:         TLNN    AC1,JNA
2036:         JRST    NOSCRU
2037:         MOVSI   TAC1,'K  '      ;ANY COMMAND BUT ↑C FORCES LOGOUT IF NOT LOGGED IN
2038: NOSCRU: MOVE    AC1,TAC1        ;COPY COMMAND.
2039:         MOVNI   AC2,1           ;SET MASK ALL ONES
2040:         LSH     AC2,-6          ;CLEAR OUT ONE MORE CHAR.
2041:         LSH     AC1,6           ;SHIFT 1 COMMAND CHAR OFF
2042:         JUMPN   AC1,.-2         ;IF NOT END OF COMMAND, GO AROUND
2043:         MOVEI   DSER,0          ;CLEAR FLAG REGISTER
2044:         MOVSI   AC1,-DISPL      ;SEARCH COMMAND TABLE FOR MATCH
2045: COMLP:  CAMN    TAC1,COMTAB(AC1);EXACT MATCH?
2046:         JRST    COMFND          ;YES, THIS IS IT. (AC1 SET WITH INDEX)
2047:         MOVE    UUO,COMTAB(AC1) ;GET FULL ENTRY NAME FROM COMMAND TABLE
2048:         TDZ     UUO,AC2         ;MASK OFF UNSPECIFIED CHARACTERS
2049:         CAME    TAC1,UUO        ;MATCH UNDER MASK?
2050:         JRST    COMNEQ          ;NO. NOT EVEN GOOD MATCH
2051:         JUMPE   DSER,.+2
2052:         TLOA    DSER,400000     ;SET SIGN BIT TO DENOTE AMBIGUOUS MATCH
2053:         MOVEI   DSER,1(AC1)     ;COPY INDEX TO DSER - FIRST MATCH UNDER MASK
2054: COMNEQ: AOBJN   AC1,COMLP       ;NO, KEEP LOOKING
2055:         JUMPLE  DSER,.+2        ;DID ONE AND ONLY ONE COMMAND MATCH?
2056:         MOVEI   AC1,-1(DSER)    ;YES. GET COMMAND INDEX THAT WE SAVED.
2057:                                 ;FALL INTO COMFND.
2058:                                 ;IF NOTHING MATCHES, WE HAVE ILLEGAL COMMAND
    CLKSER page# 0043 next  prev
2060: COMFND: MOVE    UUO,COMTAB(AC1) ;SAVE FULL COMMAND NAME
2061:         MOVE    TAC1,DISP(AC1)  ;GET DISPATCH TABLE ENTRY.
2062:         PUSH    P,TAC1          ;SAVE RH(DISPATCH ADR.+BITS)
2063:         MOVE    AC1,JBTSTS(J)   ;JOB STATUS WORD FOR THIS JOB
2064: IFN FTLOGIN,<
2065:         TLNN    AC1,JLOG        ;IS JOB LOGGED IN?
2066:         TLNE    TAC1,NOLOGIN    ;NO, CAN COMMAND PROCEED WITH NO LOGIN?
2067:         JRST    CHKNO           ;YES
2068:         TLNE    TAC1,DOLOG      ;THE REG KLUGE?
2069:         JRST    CHKNOX          ;YES.  ALLOW THIS USER TO LOGIN NOW.
2070:         JSP     TAC,COMER       ;NO, TYPE "LOGIN PLEASE"
2071:         ASCIZ   /LOGIN PLEASE
2072: /
2073: CHKNOX: MOVE    TAC1,DISP-1     ;INDEX FOR THE REG KLUDGE
2074:         MOVEM   TAC1,(P)        ;STORE THE BITS ON THE STACK AGAIN
2075: >
2076: CHKNO:
2077:         JUMPN   J,CHKRUN        ;JUMP IF JOB NUMBER ALREADY ASSIGNED.
2078:         TLNE    TAC1,NOJOBN     ;NO, DOES THIS COMMAND NEED A JOB NUMBER?
2079:         JRST    COMGO           ;NO
2080:         PUSHJ   P,INIJOB        ;INITIALIZE A JOB
2081:         JRST    JBCPEX          ;NO JOBS AVAILABLE.
2082:         JRST    [MOVEI  TAC1,DLYCM1     ;WE NEED TO WAIT FOR FREE STORAGE.
2083:                 JRST    COMDIS] ;SO WE DELAY THIS COMMAND FOR A TICK.
2084:         MOVE    TAC1,(P)        ;RESTORE TAC1 - CLOBBERED BY INIJOB
2085:         SETZM   DEVLOG(DDB)     ;CLEAR LOGICAL NAME OF TTY
2086:         JRST    CHKCO1
2087: 
2088: CHKRUN:
2089:         TLNE AC1,RUN            ;DEC 3.16
2090:         TLNN TAC1,NORUN         ;DEC 3.16
2091:         JRST CHKACT             ;DEC 3.16
2092:         MOVM AC3,JOBQUE(J)
2093:         CAIE AC3,STOPQ
2094:         JRST CNCMES
2095:         MOVSI AC3,RUN
2096:         ANDCAM AC3,JBTSTS(J)    ;NOTE!!!! THIS IS A FIX TO A BUG!!!!!!
2097:         JRST CHKACT
2098: 
2099: CNCMES: JSP TAC,COMER           ;DEC 3.16
2100:         ASCIZ /PLEASE TYPE ↑C FIRST
2101: /
2102: 
2103: JBCPEX: JSP TAC,COMER
2104:         ASCIZ /JOB CAPACITY EXCEEDED
2105: /
    CLKSER page# 0044 next  prev
2107: CHKACT:
2108: IFN JDMPRG,<
2109:         MOVE JDAT,JBTDAT(ITEM)  ;ADDRESS OF JOB DATA AREA
2110: >
2111:         MOVE PROG,JBTADR(ITEM)  ;XWD PROTECTION,RELOCATION
2112: IFN FTSWAP,<
2113:         TLNE AC1,SWP            ;ARE WE SWAPPED OUT?
2114:         SETZB PROG,JDAT         ;YES. PRETEND NO CORE.
2115:         TLNE AC1,SWP            ;IS JOB ON DISK OR ON ITS WAY?
2116:         TLNN TAC1,INCORE        ;MUST JOB BE IN CORE?
2117:         JRST CHKCO2             ;NO
2118:         TLNN TAC1,SHRINK        ;SHALL WE SHRINK HIM BEFORE BRINGING HIM IN
2119:         JRST CHKCO3             ;NO.
2120:         PUSHJ P,INTKILL         ;REG 11-11-72 KILL INTERRUPTS BEFORE SHRINK
2121:         PUSHJ P,CORX            ;SHRINK BEFORE SWAP IN. RPH 8-15-71
2122: CHKCO3: MOVEI TAC1,DLYCOR       ;YES, DELAY COMMAND.
2123:         JRST COMDIS
2124: >
2125: CHKCO2: TLNE TAC1,NOACT         ;CAN COMMAND BE PERFORMED WITH ACTIVE DEVICES?
2126:         PUSHJ PDP,RUNCHK        ;NO, RETURN IF JOB STOPPED AND NO ACTIVE DEVICES
2127: CHKCO1: TLNE TAC1,NOCORE        ;DOES THIS COMMAND NEED CORE?
2128:         JRST COMGO              ;NO. GO DISPATCH
2129:         JUMPN PROG,COMGO        ;NO, IS CORE IN MEMORY?
2130:         JSP TAC,COMER           ;NO, PRINT "NO CORE ASSIGNED"
2131:         ASCIZ /NO CORE ASSIGNED
2132: /
2133: COMER:  MOVSI TAC1,NOINCK
2134:         MOVEM TAC1,(PDP)
2135:         MOVEI TAC1,CERR         ;CALL ERROR MESSAGE ROUTINE
2136: COMGO:  MOVSI IOS,NOSKPB
2137:         ANDCAM IOS,(PDP)        ;NO. CLEAR REQUE FLAG ON STAT   ;DEC 3.16
2138:         TLZ AC1,CMWB            ;WAS JOB IN CMW?        ;DEC 3.16
2139:         MOVEM AC1,JBTSTS(ITEM)  ;DEC 3.16
2140: COMDIS: TLNE TAC1,NOPRIV        ;NEED TO CLEAR TEMPORARY PRIVILEGES?
2141:         PUSHJ P,CLRTPV          ;YES, DO IT
2142:         MOVEI IOS,0             ;CLEAR IOS FOR SETTING DISPATCH ADDRESSES
2143:         AOS NCOMS
2144:         PUSHJ PDP,(TAC1)        ;DISPATCH TO COMMAND SETUP ROUTINE.
    CLKSER page# 0045 next  prev
2146: ;RETURN FROM COMMAND SETUP ROUTINE
2147: 
2148: COMRET: POP     P,AC2           ;RESTORE COMMAND FLAGS
2149:         POP     P,DDB           ;RESTORE TTY DDB ADDRESS.
2150:         TLNN AC2,NOSKPB
2151:         PUSHJ P,COMR2A          ;SKIP TO BREAK CHAR UNLESS REQUESTED NOT TO
2152:         PUSHJ   P,COMR2B        ;DECREMENT COMCNT
2153:         TLNN    AC2,NOACT               ;DID WE STOP SPACEWAR?
2154:         JRST    COMRE1                  ;NO.
2155:         MOVSI   AC1,SPWSUS!SPWST1!SPWST2        ;PREPARE TO RESTART IT
2156:         PSYNC   SPWCSC                  ;GET CONTROL OF SPW TABLES
2157:         ANDCAM  AC1,JBTST2(J)           ;ZERO OUT THE SUSPENSION BIT
2158:         XSYNC   SPWCSC                  ;RELEASE CONTROL
2159: COMRE1: JUMPN   J,COMRT1                ;DID AN ERROR OCCUR?
2160:         TLNN    AC2,NOJOBN              ;I.E., J=0 AND NOJOBN=0?
2161:         MOVSI   AC2,NOINCK!ERRFLG       ;YES, PRINT ERROR MESSAGE ONLY.
2162: COMRT1: MOVE    AC1,JBTSTS(J)           ;JOB STATUS WORD
2163:         TLNN    AC2,NOINCK              ;SUPPRESS JOB INIT. CHECK?
2164:         TLOE    AC1,JNA                 ;NO, IS JOB INIT BIT ALREADY SET?
2165:         JRST    PCRLF                   ;YES.
2166:         MOVSI   AC1,JNA                 ;NO, SET IT THIS COMMAND
2167:         IORM    AC1,JBTSTS(J)
2168:         PUSHJ   P,TTYATI                ;ATTACH TTY TO JOB
2169:         JFCL                            ;IGNORE IF CAN NOT(SHOULD NEVER HAPPEN)
2170:         PUSHJ   P,PRJOB                 ;TYPE JOB # & CONFIG LINE
2171: IFE FTLOGIN,<
2172:         PUSHJ   P,PRSPC                 ;DEC 3.16
2173:         PUSHJ   P,DAYTIM                ;DEC 3.16       ;JS
2174: >
2175:                                         ;FALL INTO PCRLF
    CLKSER page# 0046 next  prev
2177: PCRLF:  TLNE AC2,ERRFLG         ;DID AN ERROR OCCUR?
2178:         PUSHJ PDP,PRQM          ;YES. APPEND ?
2179:         TLNN AC2,NOCRLF         ;SUPRESS CRLF?
2180:         PUSHJ PDP,CRLF          ;NO
2181:         TLNN AC2,NOPER          ;SUPRESS PRINTING PERIOD?
2182:         PUSHJ PDP,PRPER         ;NO
2183:         JUMPE ITEM,PCRLF1       ;JOB DOES NOT RUN IF ERROR 
2184:                                 ;OR NO JOB NUMBER ASSIGNED.
2185:         TLNE AC2,TTYRNU         ;JOB TO RUN WHEN TTY FINISHED TYPING?
2186:                                 ;COMMAND RESPONSE (TTY TO USER MODE)?
2187:         PUSHJ PDP,TTYUSR        ;YES, CALL SCANNER ROUTINE
2188:         TLNE AC2,TTYRNC         ;NO, JOB TO RUN AND REMAIN IN MONITOR MODE?
2189:         PUSHJ PDP,SETRUN        ;YES, CALL SCANNER ROUTINE      ;MCF(JS)
2190: PCRLF1: TLNN AC2,NOMESS         ;IS THERE A MESSAGE?
2191:         JRST TTYSTR             ;YES, START TTY TYPING IT OUT
2192:         POPJ PDP,
2193: 
2194: COMR2A: LDB     TEM,TITAKR(DDB) ;GET BREAK CHARACTER
2195:         ANDI    TEM,177
2196:         MOVEI   DAT,TTIBUF(DDB) ;IN CASE SOMEONE CLOBBERED IT.
2197: SKPBRK: PUSH PDP,TAC
2198: SKPBR2: PUSHJ PDP,SPCHEK
2199:         JRST SKPBR1
2200:         TLNE TAC,BREAKB         ; IS THIS CHAR THE BREAK?
2201:         JRST TPOPJ              ; YES, RESTORE TAC AND RETURN
2202: SKPBR1: PUSHJ PDP,GETLCCHR      ; GET A CHARACTER FROM COMMAND LINE
2203:         JUMPN TEM,SKPBR2        ; LOOK FURTHER FOR BREAK CHAR
2204:         JRST TPOPJ              ; UNLESS NO MORE CHARS
2205: 
2206: ;CALLED FROM COMMAND RETURN AND FROM DETACH (CDET,FORK,CFORK) COMMAND
2207: COMRT2: PUSHJ   PDP,COMR2A      ;SKIP TO BREAK CHAR
2208: COMR2B: MOVSI   AC1,COMBIT
2209:         LDB     TAC,PUNIT
2210:         CONO    PI,SCNOFF
2211:         SKIPGE  TTYTAB(TAC)
2212:         SOS     COMCNT
2213:         ANDCAM  AC1,TTYTAB(TAC)
2214: IFN FTTTYBUG,<
2215:         PUSHJ   P,COMBCK
2216:         PUSHJ   P,CNTCOM
2217: >
2218:         CONO    PI,SCNON
2219:         POPJ    P,
    CLKSER page# 0047 next  prev
2221: ;TABLE OF CONSOLE COMMANDS
2222: 
2223: 
2224: ;BITS CHECKED BEFORE DISPATCHING TO COMMAND SETUP ROUTINE
2225: 
2226: NOCORE←←400000  ;NO CORE NEEDED FOR COMMAND
2227: NOJOBN←←200000  ;NO JOB NUMBER NEEDED FOR COMMAND
2228: NOLOGIN←←100000 ;JOB DOES NOT NEED TO BE ALREADY LOGGED IN.
2229: NOACT←←40000    ;COMMAND MUST BE DELAYED IF JOB HAS ACTIVE DEVICES.
2230: INCORE←←20000   ;COMMAND MUST BE DELAYED IF JOB HAS CORE ASSIGNED
2231:                 ;AND IS NOT IN CORE.
2232: NORUN←←10000            ;↑C MUST BE TYPED BEFORE COMMAND CAN BE
2233:                 ;EXECUTED.
2234: SHRINK←←4000    ;IF JOB ON DISK, SHRINK BEFORE BRINGING HIM IN!!!
2235:                 ;THIS SHOULD SAVE A LOT OF TIME
2236: NOPRIV←←2000    ;CLEAR TEMPORARY PRIVILEGE BITS BEFORE DISPATCHING
2237: 
2238: 
2239: ;BITS CHECKED AFTER RETURN FROM COMMAND SETUP ROUTINE
2240: NOSKPB←←4000    ;DON'T CALL SKPBRK (SEE US RECYCLE THOSE BITS!)
2241: ;NODATE←←1000   ;DONT PRINT DATE AFTER JOB INITIALIZATION
2242: NOINCK←←400     ;NO CHECK FOR JOB INITIALIZATION (JNA=0)
2243: NOCRLF←←200     ;NO PRINTING OF CRLF
2244: NOPER←←100      ;NO PRINTING OF PERIOD
2245: TTYRNU←←40      ;SET TTY TO USER MODE AND START JOB
2246:                 ;WHEN COMMAND RESPONSE STOPS TYPING
2247: TTYRNC←←20      ;KEEP TTY IN COMMAND MODE AND START JOB
2248:                 ;WHEN COMMAND RESPONSE STOPS TYPING
2249: NOMESS←←10      ;NO COMMAND RESPONSE EVER, DO NOT CALL TTYSTR
2250: DOLOG←←4        ;ALLOW LOGIN FIRST
2251: 
2252: 
2253: ERRFLG←←1       ;COMMAND ERROR
2254: 
2255: RPGBIT←←NOCORE!NOPER!NOCRLF!INCORE!NORUN!NOACT!TTYRNU!SHRINK!DOLOG!NOPRIV
2256:                         ;BITS FOR THE RPG COMMANDS
    CLKSER page# 0048 next  prev
2258: DEFINE NAMES
2259: <
2260:         C KJOB,KJOB,NOCORE!NOJOBN!NOINCK!NOLOGIN!NOACT!NORUN!NOCRLF!NOPER!NOMESS!INCORE!SHRINK
2261:         C LOGOUT,KJOB,NOCORE!NOJOBN!NOINCK!NOLOGIN!NOACT!NORUN!NOCRLF!NOPER!NOMESS!INCORE!SHRINK
2262:         C K,KJOB,NOCORE!NOJOBN!NOINCK!NOLOGIN!NOACT!NORUN!NOCRLF!NOPER!NOMESS!INCORE!SHRINK
2263:         C KATTACH,KJOB,NOCORE!NOJOBN!NOINCK!NOLOGIN!NOACT!NORUN!NOCRLF!NOPER!NOMESS!INCORE!SHRINK
2264:         C KLOG,KJOB,NOCORE!NOJOBN!NOINCK!NOLOGIN!NOACT!NORUN!NOCRLF!NOPER!NOMESS!INCORE!SHRINK
2265:         C START,START,NOPER!TTYRNU!INCORE!NOACT!NORUN
2266:         C S,START,NOPER!TTYRNU!INCORE!NOACT!NORUN       ;JS
2267:         C HALT,STOP,NOCORE!NOJOBN!NOLOGIN!NOINCK
2268:         C KILL,KILCOM,NOCORE
2269:         C FLUSH,FLUSH,NOINCK!NOLOGIN!NOJOBN!NOCORE
2270:         C <>,CBLANK,NOCORE!NOJOBN!NOLOGIN!NOINCK!NOCRLF
2271:         C R,RCOM,NOCORE!NOPER!TTYRNU!NOCRLF!INCORE!NOACT!NORUN!SHRINK!DOLOG!NOPRIV
2272:         C RUN,RUNCOM,NOCORE!NOPER!TTYRNU!NOCRLF!INCORE!NOACT!NORUN!SHRINK!DOLOG!NOPRIV
2273: IFN FTLOGIN,<
2274:         C CORE,CORE,NOCORE!NOACT!NOLOGIN!NORUN!NOINCK!NOJOBN
2275:         C C,CORE,NOCORE!NOACT!NOLOGIN!NORUN!NOJOBN!NOINCK
2276: >
2277: IFE FTLOGIN,<   ;IN NON-LOGIN SYSTEM, CORE COMMAND MAY MAKE A JOB.
2278:         C CORE,CORE,NOCORE!NOACT!NOLOGIN!NORUN
2279:         C C,CORE,NOCORE!NOACT!NOLOGIN!NORUN
2280: >
2281:         C SETUWP,SETWPS,NOACT!NOCORE!NOPRIV             ;RPH SET SEGMENT WRITE PROT
2282:         C CLRUWP,CLRWPS,NOACT!NOCORE!NOPRIV             ;RPH CLEAR SEGMENT WRITE PROT
2283:         C ENABLE,ENABLE,NOCORE
2284:         C DISABLE,DISABLE,NOCORE
2285:         C GET,GET,NOCRLF!NOPER!TTYRNU!INCORE!NOCORE!NOACT!NORUN!SHRINK!DOLOG!NOPRIV
2286:         C G,GET,NOCRLF!NOPER!TTYRNU!INCORE!NOCORE!NOACT!NORUN!SHRINK!DOLOG!NOPRIV
2287:         C SAVE,SAVE,NOCRLF!NOPER!TTYRNU!INCORE!NOACT!NORUN!NOPRIV
2288:         C SSAVE,SSAVE,NOCRLF!NOPER!TTYRNU!INCORE!NOACT!NORUN!NOPRIV
2289:         C CONTINUE,CONT,NOPER!TTYRNU!INCORE!NORUN
2290:         C DE,DCOM,INCORE!NOPRIV
2291:         C E,ECOM,NOCRLF!INCORE
2292:         C PJOB,PJOBDV,NOCORE!NOLOGIN!NOJOBN!NOINCK
2293:         C PTTY,PTTY,NOCORE!NOJOBN!NOINCK!NOLOGIN
2294: IFN FTDSKPPN,<
2295:         C ALIAS,SDSKPPN,NOCORE!NOPRIV                   ;RPH
2296: >
2297:         C SLEVEL,SLEVEL,NOCORE
2298:         C ASSIGN,ASSIGN,NOCORE!DOLOG!NOPRIV
2299:         C A,ASSIGN,NOCORE!DOLOG!NOPRIV                  ;JS
2300:         C DEASSI,DEASSIGN,NOCORE
2301:         C D,DEASSIGN,NOCORE
2302:         C DDT,DDTGO,NOPER!TTYRNU!INCORE!NORUN!NOPRIV
2303:         C TTY,TTYSUB,NOLOGIN!NOCORE!NOJOBN!NOINCK       ;RPH
2304:         C FINISH,FINIS,NOPER!NOACT!INCORE!NORUN!NOPRIV
2305:         C F,FINIS,NOPER!NOACT!INCORE!NORUN!NOPRIV
2306:         C REENTER,REENTER,TTYRNU!NOPER!INCORE!NORUN
2307:         C CSTART,STARTC,TTYRNC!INCORE!NORUN
2308:         C CCONTINUE,CONTC,TTYRNC!INCORE!NORUN
2309:         C DETACH,DETACH,NOCORE!NOINCK!NOPER!NOCRLF!NOMESS
2310:         C CDETACH,CDETACH,NOCORE!NOINCK
2311:         C ATTACH,ATTACH,NOCORE!NOJOBN!NOLOGIN!NOINCK
2312:         C DAYTIME,DAYTIM,NOCORE!NOJOBN!NOLOGIN!NOINCK
2313:         C EDDT,CEDDT,NOCORE!NOJOBN!NOLOGIN!NOINCK
2314:         C TIME,RUNTIM,NOCORE!NOLOGIN!NOINCK!NOJOBN
2315:         C RESOURCES,FREDEV,NOCORE!NOJOBN!NOLOGIN!NOINCK
2316:         C FILES,FILCOM,NOCORE!NOJOBN!NOLOGIN!NOINCK
2317:         C REASSI,REASS,NOCORE!NOACT!INCORE!NORUN
2318:         C TALK,TALK,NOCORE!NOJOBN!NOLOGIN!NOMESS!NOINCK!NOCRLF!NOPER
2319:         C HELLO,HELLO,NOCORE!NOLOGIN!NOJOBN!NOINCK      ;JS
2320: IFN FTLOGIN,<
2321:         C LOGIN,CLOGIN,NOCORE!NOLOGIN!NOPER!TTYRNU!INCORE!NOACT!NORUN
2322:         C L,CLOGIN,NOCORE!NOLOGIN!NOPER!TTYRNU!INCORE!NOACT!NORUN
2323:         C PPPN,PPPN,NOLOGIN!NOCORE!NOJOBN!NOINCK
2324:         C FORK,FORK,NOINCK!NOMESS!NOPER!NOCRLF!NOCORE!NOPRIV
2325:         C CFORK,CFORK,NOINCK!NOMESS!NOPER!NOCRLF!NOCORE!NOPRIV
2326: >
    CLKSER page# 0049 next  prev
2328: ; MORE COMMANDS . . .
2329: IFN FTDISK,<
2330:         C HELP,HELP,RPGBIT!NOLOGIN
2331:         C WHERE,WHECOM,RPGBIT!NOLOGIN
2332:         C SYSTAT,WHOCOM,RPGBIT!NOLOGIN
2333:         C WHO,WHOCOM,RPGBIT!NOLOGIN
2334:         C W,WHOCOM,RPGBIT!NOLOGIN
2335:         C FINGER,FINGER,RPGBIT!NOLOGIN
2336:         C FIND,FNDCOM,RPGBIT!NOLOGIN
2337:         C FIXIML,FIXIML,RPGBIT!NOLOGIN
2338: 
2339:         C LISP,LSPCOM,RPGBIT
2340:         C RSL,RSLCOM,RPGBIT
2341: 
2342:         C COMPILE,RPGCOM,RPGBIT                 ;RPG COMMANDS
2343:         C DEBUG,RPGCOM,RPGBIT
2344:         C PREPARE,RPGCOM,RPGBIT
2345:         C LOAD,RPGCOM,RPGBIT
2346:         C EXECUTE,RPGCOM,RPGBIT
2347:         C CREF,RPGCOM,RPGBIT
2348:         C TV,RPGCOM,RPGBIT
2349:         C CTV,RPGCOM,RPGBIT
2350:         C EDIT,RPGCOM,RPGBIT
2351:         C ED,RPGCOM,RPGBIT
2352:         C CREATE,RPGCOM,RPGBIT
2353:         C TECO,RPGCOM,RPGBIT
2354:         C MAKE,RPGCOM,RPGBIT
2355:         C TRY,RPGCOM,RPGBIT
2356:         C PUB,RPGCOM,RPGBIT
2357: 
2358:         C READ,ETCOM,RPGBIT
2359:         C ETV,ETCOM,RPGBIT
2360:         C CETV,ETCOM,RPGBIT
2361: 
2362:         C LIST,CPYCOM,RPGBIT                    ;COPY COMMANDS
2363:         C DIRECTORY,CPYCOM,RPGBIT
2364:         C DI,CPYCOM,RPGBIT
2365:         C DELETE,CPYCOM,RPGBIT
2366:         C RENAME,CPYCOM,RPGBIT
2367:         C TYPE,CPYCOM,RPGBIT
2368:         C COPY,CPYCOM,RPGBIT
2369:         C PRINT,CPYCOM,RPGBIT
2370:         C TRANSFER,CPYCOM,RPGBIT
2371:         C XGPLIST,CPYCOM,RPGBIT
2372: 
2373:         C SEND,MAICOM,RPGBIT                    ;MAIL AND REMINDERS
2374:         C MAIL,MAICOM,RPGBIT
2375:         C GRIPE,MAICOM,RPGBIT
2376:         C REMIND,MAICOM,RPGBIT
2377:         C CANCEL,OBLCOM,RPGBIT                  ;DELETE REMINDERS
2378:         C LATER,MAICOM,RPGBIT
2379:         C RCV,RCVCOM,RPGBIT!NOLOGIN
2380:         C PLAN,MAICOM,RPGBIT
2381: 
2382:         C SPOOL,SPLCOM,RPGBIT                   ;SPOOLER
2383:         C QSPOOL,SPLCOM,RPGBIT!NOLOGIN
2384:         C UNSPOOL,SPLCOM,RPGBIT
2385:         C XSPOOL,SPLCOM,RPGBIT
2386: 
2387:         C ZERO,ZERCOM,RPGBIT
2388:         C XEROX,XERCOM,RPGBIT
2389:         C DO,DOCOM,RPGBIT
2390:         C TEST,TSTCOM,RPGBIT
2391: 
2392:         C REWIND,DSCCOM,RPGBIT          ;DUMP COMMAND RUN DART NOW.
2393:         C DUMP,DSCCOM,RPGBIT            ;IDUMP COMMAND IS FLUSHED.
2394:         C RESTOR,DSCCOM,RPGBIT
2395:         C ADVANC,DSCCOM,RPGBIT
2396:         C BACKSP,DSCCOM,RPGBIT
2397:         C TLIST,DSCCOM,RPGBIT
2398:         C EOT,DSCCOM,RPGBIT
2399:         C LOCATE,DSCCOM,RPGBIT
2400: 
2401:         C TN,TNCOM,RPGBIT
2402:         C TELNET,TNCOM,RPGBIT
2403:         C FTP,FTPCOM,RPGBIT
2404: 
2405:         C DIAL,DILCOM,RPGBIT
2406: 
2407:         C NS,NSCOM,RPGBIT               ;NEWS SERVICE--USES TEMPORARY PRIVILEGES
2408:         C HOT,HOTCOM,RPGBIT             ;NEWS SERVICE HOT LINE WITH TEMP PRIV
2409: 
2410:         C UDPUFD,UDPCOM,RPGBIT          ;UDP UFD MUNGER LOTSA PRIVS
2411: >>
    CLKSER page# 0050 next  prev
2413: BEGIN COMTBL                    ;GENERATE TABLE OF SIXBIT COMMAND NAMES
2414: 
2415: DEFINE C(A,B,C),<
2416:         <SIXBIT /A/>            ;ONLY FIRST SIX CHARACTERS.
2417: >
2418: 
2419: ↑↑COMTAB:
2420:         XLIST
2421:         NAMES
2422:         LIST
2423: ↑↑DISPL←.-COMTAB        ;LENGTH OF TABLE
2424: 
2425: ;GENERATE THE DISPATCH TABLE AND SPECIAL BITS
2426: 
2427: DEFINE C!(A,B,D)
2428: <       XWD D,B>
2429: 
2430: ;SPECIAL HACK TO FORCE LOGIN FROM "ANY" COMMAND.
2431:         XWD NOCORE!NOLOGIN!NOPER!TTYRNU!INCORE!NOACT!NORUN,CXLOGI
2432: DISP:
2433:         XLIST
2434:         NAMES
2435:         LIST
2436: 
2437:         XWD NOCORE+NOJOBN+NOLOGIN+NOINCK,NOCOM  ;CATCH ANYTHING THAT'S NOT A COMMAND
2438: 
2439: BEND COMTBL
    CLKSER page# 0051 next  prev
2441: ;CALLED FROM COMMAND DECODER WHICH IS CALLED FROM CLOCK ROUTINE
2442: ;WITH FOLLOWING AC'S SET:
2443: ;TAC= BYTE POINTER TO COMMAND STRING(SPACE OR CR AFTER COMMAND NAME)
2444: ;ITEM = JOB NUMBER
2445: ;DAT = BYTE POINTER TO LAST OUTPUT CHARACTER
2446: ;DEVDAT= ADDRESS OF DEVICE DATA BLOCK INITIATING COMMAND
2447: ;JDAT = ADDRESS OF JOB DATA AREA, = 0 IF NO JOB AREA
2448: ;PROG=XWD PROTECTION,RELOCATION; 0 IF NO CORE
2449: ;IOS=0
2450: 
2451: ;UPON RETURN FROM COMMAND SETUP ROUTINE, A CR-LF IS ADDED IF
2452: ;NEEDED AND TTY IS STARTED
2453: 
2454: ;SINCE THE COMMAND DECODER IS CALLED FROM THE CLOCK ROUTINE
2455: ;COMMAND SETUP ROUTINES MUST RUN TO COMPLETION QUICKLY
2456: ;IF A COMMAND FUNCTION CANNOT DO THIS, IT MUST JUST SET
2457: ;THE JOB TO A RUNABLE STATUS AND RETURN IMMEDIATELY
2458: 
2459: 
2460: 
2461: CEDDT:  PUSHJ P,STLNAC          ;SET UP LINE(TAC1)
2462:         TLNN TAC1,CTYLIN        ;IS HE ON THE CTY?
2463:         JRST COMERR             ;NO, FLUSH HIM
2464:         JRST DDTCAL             ;YES, GET EXEC DDT
    CLKSER page# 0052 next  prev
2466: COR0:           ;CALLED FROM CORE COMMAND TO ZERO CORE
2467:         JUMPE PROG,CPOPJ        ;RETURN IF JOB DOES NOT HAVE CORE
2468:         MOVSI TAC,TTYRNU!NOPER!NOCRLF
2469:         IORM TAC,-1(P)          ;TELL COMRET TO PUT TTY IN USER MODE
2470:         JSP TAC1,MONJOB         ;SET TO RUN MONITOR JOB(PC IN EXEC MODE)
2471:                                 ;RETURN HERE AT UUO LEVEL(NO ACS SET UP)
2472:         MOVEI TAC1,HOLD         ;PUT ERROR STOP ON END OF PDL
2473:         JSP TAC,MONSTR          ;START MONITOR JOB BY SETTING UP ACS AND
2474: JOB1:   PUSHJ   P,RESET         ;RELEASE ALL IO DEVICES ASSIGNED TO THIS JOB
2475:         PUSHJ   P,TTYFNU        ;FIND TTY FOR THIS JOB(SETUP ITEM WITH JOB NO.)
2476:         PUSHJ   P,NOCORQ        ;PUT JOB IN NO CORE Q
2477:         MOVEI   TAC,0           ;FLUSH ALL CORE
2478:         SOS     (P)             ;CORE1 WILL SKIP RETURN
2479: IFN FTSWAP,<
2480:         SETZM   JBTSWP(J)       ;CLEAR IMGIN AND IMGOUT
2481:         SETOM   STIME(J)        ;MARK CORE IMAGE ALTERED
2482:         LDB     DAT,PSEGN
2483:         MOVE    TEM,JBTSTS(DAT)
2484:         TLNN    TEM,JWP
2485:         SETOM   STIME(DAT)
2486: >
2487:         JRST    CORE1
    CLKSER page# 0053 next  prev
2489: ;PTTY PJOB KJOB
2490: ; "PTTY" GIVES THE LOGICAL NAME OF THE TTY THE LOSER IS ON.
2491: ; "PTTY N" GIVES THE LOGICAL NAME OF THE TTY FOR JOB N.
2492: 
2493: PTTY:   PUSHJ P,DECIN   ;JOB NUMBER MAYBE?
2494:         JRST PTTY1
2495:         JRST COMERA
2496:         JUMPE TAC1,NOTLOG
2497:         CAIL TAC1,JOBN          ;LEGAL?
2498:         JRST NOTLOG             ;NONE SUCH JOB
2499:         MOVE TAC,JBTSTS(TAC1)
2500:         TLNN TAC,JNA            ;DOES HE HAVE A JOB NUMBER?
2501:         JRST NOTLOG             ;NO, LOSE
2502:         MOVE AC1,JBTLIN(TAC1)   ;LINE NUMBER
2503:         CAMN AC1,[-1]           ;DETACHED?
2504:         JRST PTTYDT             ;YES
2505:         TLNN AC1,CTYLIN         ;CTY?
2506:         JRST NOTCTY
2507:         JSP TAC,CONMES
2508:         ASCIZ/CTY
2509: /
2510: NOTCTY: PUSH P,AC1
2511:         PUSHJ P,INLMES
2512:         ASCIZ/TTY/
2513:         POP P,TAC
2514:         HRRZS TAC
2515:         PUSHJ P,OCTPNT
2516:         JRST PTTY2
2517: 
2518: PTTY1:  MOVE TAC1,DEVNAM(DDB)
2519:         PUSHJ P,PRNAME
2520:         LDB AC1,PUNIT
2521:         HLL AC1,LINTAB(AC1)
2522: PTTY2:  TLNN AC1,DDDLIN
2523:         JRST CRLF
2524:         PUSHJ P,INLMES
2525:         ASCIZ /, DD/
2526:         MOVE AC1,LETAB-DPYL0(AC1);NONZERO IT SAYS HERE
2527:         HLRZ TAC,PRGNUM(AC1)
2528:         PUSHJ P,OCTPNT
2529:         JRST CRLF
2530: 
2531: PTTYDT:
2532:         JSP TAC,CONMES
2533:         ASCIZ/DETACHED.
2534: /
2535: 
2536: ; "PJOB" PRINT JOB NUMBER OF JOB TTY IS ATTACHED TO
2537: ; "PJOB TTYN" PRINT JOB NUMBER OF JOB USING TTYN.
2538: 
2539: PJOBDV: PUSHJ P,CTEXT1          ;ARG
2540:         JUMPN TAC1,PJOBX
2541:         JUMPE ITEM,LOGPLS
2542: PJOB:  MOVE TAC,ITEM           ;JOB NO.
2543: DECLF: PUSHJ PDP,RADX10        ;PRINT TAC AS DEC. THEN CRLF
2544:         JRST CRLF
2545: 
2546: PJOBX:  MOVE TAC,TAC1
2547:         PUSH P,TAC
2548:         PUSHJ P,DEVPHY
2549:         SKIPA DDB,-3(P)                 ;(SO I DON'T CARE IF DEVPHY MUNGS IT)
2550:         JRST FNDDEV
2551:         PUSHJ P,DADD00                  ;NOT DEVICE, PERHAPS DD CHAN
2552:         JRST PJDVLZ                     ;NOPE, NO SUCH FROBULE
2553:         LDB TAC1,[DDUSR+<(TAC)>]        ;YES, GET USE CODE
2554:         JUMPE TAC1,DEVFRE               ;0, NOT IN USE
2555:         CAIGE TAC1,100                  ;IF LESS THAN 100,
2556:         JRST FNDDV1                     ;  IT'S ASSIGNED TO THAT JOB
2557:         CAIL TAC1,200                   ;ABOVE 200,
2558:         JRST DEVFR2                     ;  DETACHED FROM SYS (OR AVLCHN)
2559:         SUBI TAC1,100-DDL0              ;ELSE MAKE IT A TTY LINE NUMBER
2560:         PUSH P,TAC1
2561:         MOVEI AC1,(TAC1)
2562:         PUSHJ P,NOTCTY                  ;THIS WILL TYPE THE TTY NUMBER
2563:         POP P,TAC1
2564: FNDDV0: SKIPN DDB,TTYTAB(TAC1)  ;DOES IT HAVE A DDB
2565:         JRST DEVFRE             ;NO ONE HAS IT
2566: FNDDEV: MOVE TAC1,DEVMOD(DDB)           ;SPECIAL HAIR FOR UDP AS USUAL
2567:         TLNE TAC1,DVUDP
2568:         JRST PJBUDP
2569:         LDB TAC1,PJOBN
2570: FNDDV1: JUMPE TAC1,DEVFR1
2571:         PUSH P,TAC              ;SORRY ABOUT THIS
2572:         PUSHJ P,PJPRNM
2573:         POP P,TAC
2574:         PUSHJ P,INLMES
2575:         ASCIZ/ ASSIGNED TO JOB /
2576:         POP P,TAC
2577:         JRST DECLF
2578: 
2579: PJBUDP: LDB TAC,PUNIT                   ;UDP: GET INDEX TO TABLES
2580:         SKIPL TAC1,UDPOWN-1(TAC)
2581:         JRST FNDDV1                     ;PRIVATELY OWNED, DO THE USUAL THING
2582:         SKIPN UDPCNT-1(TAC)
2583:         JRST DEVFRE                     ;NO DDBS, NOT IN USE
2584:         PUSH P,TAC
2585:         PUSHJ P,PJPRNM
2586:         POP P,TAC
2587:         SKIPE TAC,SATADR(TAC)
2588:         PUSHJ P,SATTAC                  ;PRINT SATID IF ANY
2589:         POP P,(P)
2590:         JSP TAC,CONMES
2591:         ASCIZ / PUBLIC
2592: /
2593: 
2594: PJDVLZ: POP P,(P)
2595:         MOVE DDB,-2(P)
2596:         MOVEI DAT,TTOBUF(DDB)
2597:         JRST NOTDEV
2598: 
2599: DEVFR1: MOVE TAC1,DEVMOD(DDB)
2600:         TRNN TAC1,ASSCON                ;DETACHED MAYBE?
2601:         JRST DEVFRE
2602: DEVFR2: JSP TAC,PJBMSG
2603:         ASCIZ/DETACHED FROM SYSTEM.
2604: /
2605: 
2606: DEVFRE: JSP TAC,PJBMSG
2607:         ASCIZ/NOT IN USE.
2608: /
2609: 
2610: PJBMSG: POP P,(P)
2611:         MOVE DDB,-2(P)
2612:         MOVEI DAT,TTOBUF(DDB)
2613:         JRST CONMES
2614: 
2615: PJPRNM: MOVE DDB,-5(P)
2616:         MOVEI DAT,TTOBUF(DDB)
2617:         EXCH TAC1,-2(P)
2618:         JRST PRNAME
2619: 
2620: ;  "KJOB" KILL ATTACHED JOB
2621: 
2622: 
2623: 
2624: KJOB:   JUMPE ITEM,JOBKB        ;WAS JOB INITIALIZED?   ;DEC 3.16
2625: IFN FTSWAP,<
2626:         TLNN AC1,SWP            ;DEC 3.16
2627:         JRST KJOB1              ;DEC 3.16
2628:         JUMPN PROG,DLYCR1       ;DEC 3.16
2629: CORX:   MOVEI TAC,1             ;DEC 3.16
2630:         PUSH PDP,CORX1          ;DEC 3.16
2631:         JRST CORE0K             ;DEC 3.16
2632: KJOB1:
2633: >       
2634: IFN FTLOGIN,<
2635:         PUSHJ P,STLNAC          ;GET TTY BITS
2636:         TLNN TAC1,IMPBIT        ;IMP'S GET LOGGED OUT ANYWAY
2637:         TLNN TAC1,PTYLIN        ;FLUSH PTY JOBS INSTANTLY!
2638:         TLZN AC1,JLOG!JACCT     ;SHALL WE RUN LOGOUT?
2639:         JRST KJOB2              ;NO.
2640:         TLO AC1,JACCT           ;SET "ACCOUNTING PGM RUNNING"
2641:         HLLM AC1,JBTSTS(ITEM)
2642: IFN FTSWAP,<
2643:         PUSHJ PDP,ALOGN1
2644: >
2645:         MOVSI TAC,TTYRNU+NOMESS
2646:         XORM TAC,-1(PDP)
2647:         PUSH PDP,['LOGOUT']
2648:         JRST ARCOM              ;RUN LOGOUT
2649: >
    CLKSER page# 0054 next  prev
2651: IFN FTLOGIN,<                   ; PRINT OUT A JOB'S PROJECT PROGRAMMER NUMBER
2652: 
2653: PPPN:   PUSHJ   P,DECIN         ;GET ARGUMENT, IF ANY
2654:         JRST    PPPN6           ;NO ARGUMENT. PPN FOR CURRENT JOB.
2655:         JRST    COMERA          ;ILL. ARGUEMENT
2656:         MOVSI   TAC,NOINCK      ;DON'T INITIALIZE A JOB JUST FOR ME!
2657:         IORM    TAC,-1(P)
2658:         CAIGE   TAC1,JOBN       ; OUT OF BOUNDS?
2659:         CAIG    TAC1,0
2660:         JRST    ECOMA           ; PRINT "OUT OF BOUNDS"
2661:         MOVE    AC1,TAC1        ; USE THAT JOB NUMBER
2662: PPPN5:  MOVE    TAC,JBTSTS(AC1)
2663:         SKIPE   PRJPRG(AC1)
2664:         TLNN    TAC,JNA
2665:         JRST    NOTLOG
2666:         MOVE    TAC,[POINT 6,PRJPRG(AC1)]
2667:         PUSHJ   P,PPPN7         ;WRITE 3 SIXBIT CHARACTERS
2668:         MOVEI   TEM,","
2669:         XCT     TYO
2670:         PUSHJ   P,PPPN7         ;TYPE THE REST
2671: IFN FTDSKPPN,<
2672:         SKIPN   DSKPPN(AC1)     ;ANY ALIAS PPN?
2673:         JRST    NOALIAS
2674:         PUSHJ   P,INLMES
2675:         ASCIZ/  ALIAS  /
2676:         MOVE    TAC,[POINT 6,DSKPPN(AC1)]
2677:         PUSHJ   P,PPPN7
2678:         MOVEI   TEM,","
2679:         XCT     TYO
2680:         PUSHJ   P,PPPN7
2681: NOALIAS:
2682: >;FTDSKPPN
2683:         PUSHJ   PDP,INLMES
2684:         ASCIZ /
2685: /
2686:         POPJ    PDP,
2687: 
2688: PPPN6:  MOVEI   AC1,(J)         ; NO ARGUMENT USE PPN OF CURRENT JOB
2689:         MOVE    AC2,JBTSTS(J)
2690:         TLNN    AC2,JLOG
2691:         JRST    LOGPLS
2692:         JRST    PPPN5
2693: 
2694: PPPN7:  MOVEI   TAC1,3          ;3 CHARACTERS
2695: PPPN8:  ILDB    TEM,TAC         ;LOAD THE NEXT BYTE
2696:         JUMPE   TEM,PPPN9       ;FLUSH NULL BYTES
2697:         ADDI    TEM," "         ;MAKE SIXBIT INTO ASCII
2698:         XCT     TYO             ;TYPE ONE CHARACTER
2699: PPPN9:  SOJG    TAC1,PPPN8      ;LOOP
2700:         POPJ    P,
2701: >
2702: 
2703: ;COMMAND        "ALIAS P,PN"  OR  "ALIAS P"  OR  "ALIAS"
2704: ;THE FIRST SETS DSKPPN(J) AND THE SECOND RESETS IT
2705: IFN FTDSKPPN,<
2706: SDSKPPN:
2707:         CAIE    TEM,";"
2708:         CAIN    TEM,12          ;TERMINATOR SEEN ALREADY?
2709:         JRST    CDSKPPN         ;YES. RESET ALIAS.
2710:         PUSHJ   P,GETWRB        ;LOOK FOR ARG
2711:         JUMPE   TAC1,[  CAIE TEM,12     ;NO ARG AT ALL?
2712:                         CAIN TEM,";"
2713:                         JRST CDSKPPN    ;NO ARG IS OK
2714:                         JRST COMERA]    ;BAD ARG, ERROR
2715:         HLLZ    AC2,TAC1        ;SAVE P
2716:         TRNE    TAC1,-1         ;CHECK SYNTAX, RPH YOU LAZY ...
2717:         JRST    COMERA
2718:         CAIE    TEM,";"
2719:         CAIN    TEM,12          ;ONE ARG?
2720:         JRST    [HRR AC2,PRJPRG(J)      ;COPY PRG
2721:                 JRST CNGPRJ]
2722: ;       CAIE    TEM,","         ;COMMA FOR SEPERATOR?
2723: ;       CAIN    TEM,"/"         ;OR SLASH?
2724: ;       CAIA                    ;YES
2725: ;       JRST    COMERA          ;NO
2726:         PUSHJ   P,GETWRB        ;TRY TO GET PN
2727:         JUMPE   TAC1,COMERA     ;MUST BE ONE
2728:         HLR     AC2,TAC1        ;DON'T CARE ABOUT TERMINATOR HERE
2729:         TRNE    TAC1,-1
2730:         JRST    COMERA
2731: CNGPRJ: CAMN    AC2,MFDENT      ;SAME AS 1,1?
2732:         JRST    COMERA          ;SOME THINGS NOT ALLOWED.
2733:         CAMN    AC2,PRJPRG(J)   ;RESETING EXPLICITLY
2734: CDSKPPN:SETZ    AC2,
2735:         CAME    AC2,DSKPPN(J)   ;CHANGING?
2736:         SETZM   JBTUFD(J)       ;YES, CLEAR JBTUFD
2737:         MOVEM   AC2,DSKPPN(J)
2738:         POPJ    P,
2739: 
2740: GETWRB: PUSHJ P,CTEXT
2741:         JUMPE TAC1,NOJUST
2742:         TLNN TAC1,7777
2743:         LSH TAC1,-14
2744:         TLNN TAC1,77
2745:         LSH TAC1,-6
2746: NOJUST: PUSHJ P,SKIPSB          ;CAREFUL, THIS GUY CAN CALL TPOPJ
2747:         POPJ P,
2748: >;FTDSKPPN
2749: 
2750: NOTLOG:JSP TAC,ERRMES
2751:         ASCIZ /NO SUCH JOB
2752: /
    CLKSER page# 0055 next  prev
2754: ; SERVICE LEVEL COMMAND
2755: ; SLEVEL
2756: ; YOUR CURRENT SERVICE LEVEL IS PRINTED.
2757: 
2758: MAXLEV ←← =80           ;NOBODY CAN HAVE MORE THAN 80% OF THE MACHINE
2759: 
2760: SLEVEL:
2761: TYPSL:  PUSHJ   P,SPRSSL                ;MAKE SURE CURRENT SERVICE LEVEL IS SPREAD
2762:                                         ;SPRSSL IS IN UUOCON
2763:         HRRZ    TAC,JBTGSL(J)
2764:         IMULI   TAC,=100
2765:         ADDI    TAC,400000              ; TRY TO CORRECT FOR ROUNDOFF ERROR
2766:         HLRZS   TAC
2767:         PUSHJ   P,RADX10
2768:         JSP     TAC,CONMES
2769:         ASCIZ   /% SERVICE LEVEL
2770: /
    CLKSER page# 0056 next  prev
2772: ;KILL N ---- KILL JOB N IMMEDIATELY! -- OR MAYBE LATER
2773: KILCOM: PUSHJ   P,DECIN                 ;GET ARGUMENT
2774:         JRST    NOTENF                  ;NONE
2775:         JRST    COMERA                  ;ILLEGAL
2776:         CAMN    J,TAC1                  ;NO SUICIDE!
2777:         JRST    ILLKIL
2778:         CAIL    TAC1,JOBN               ;LEGAL?
2779:         JRST    NOTLOG                  ;TOO BIG
2780:         JUMPLE  TAC1,NOTLOG             ;TOO SMALL
2781:         MOVE    TAC,JBTSTS(TAC1)
2782:         TLNN    TAC,JNA                 ;LEAVE US NOT FLUSH NON-EX JOBS
2783:         JRST    NOTLOG
2784:         TLNE    TAC,JSEG                ;IS IT SEG2.
2785:         JRST    KILCM5                  ;JUST CHANGE NAME OF UPPER SEGMENT.
2786:         MOVSI   AC1,KILPRV              ;LOOK FOR KILL PRIVILEGE
2787:         TDNE    AC1,JBTPRV(J)           ;...
2788:         JRST    KILOK                   ;HE HAS THE POWER
2789:         HRRZ    AC1,PRJPRG(ITEM)        ;GET PROGRAMMER NAME
2790:         HRRZ    TAC,PRJPRG(TAC1)        ;GET PRG OF GUY WE'RE KILLING
2791:         CAME    TAC,AC1                 ;SAME
2792:         JRST    NOTYRS                  ;LOSE!
2793: KILOK:  MOVE    TAC,JBTSTS(TAC1)
2794:         TLNE    TAC,SHF
2795:         JRST    DLYCM                   ;WAIT A WHILE
2796:         PUSH    P,J                     ;SAVE ME
2797:         PUSH    P,PROG                  ;AND MY JOB
2798:         MOVE    J,TAC1                  ;MAKE BELIEVE I'M HIM
2799:         MOVE    PROG,JBTADR(J)          ;AND HIS JOB
2800:         TLNE    TAC,SWP                 ;SWAPPED OUT?
2801:     ;NEXT INSTRUCTION MAY BE HAZZARDOUS TO YOUR HEALTH IF TWIDDLED.
2802:         JRST    KILCM3                  ;GET HIM IN
2803:         JUMPE PROG,KILCM7               ;ANY CORE?
2804:         MOVE TAC,(P)
2805:         MOVE TAC,JBTPRV(TAC)            ;GET PRIVILEGES OF GUY WHO TYPED COMMAND
2806:         TLNE TAC,KILPRV                 ;IF HE HAS THE PRIV
2807:         JRST KILCM6                     ;HE CAN KILL WITH ACTIVE IO
2808:         PUSHJ PDP,ANYACT                ;YES, ARE DEVICES ACTIVE?
2809:         JRST KILCM3                     ;YES, DELAY
2810:         JRST KILCM6                     ;WE HAVE CORE AND NO ACTIVE DEVICES
2811: 
2812: KILCM7: MOVEI   TAC,JOBDA               ;NO, JUST GET A JOB DATA AREA
2813:         PUSHJ   P,CORE0                 ;MAKE SURE HE HAS CORE
2814:         JFCL
2815:         JUMPE   PROG,KILCM4             ;IF WE DON'T HAVE CORE HERE WE LOSE.
2816: KILCM6: MOVSI TAC1,CMWB                 ;CLEAR COMMAND WAIT BIT
2817:         ANDCAM TAC1,JBTSTS(J)           ;SO HE WILL RUN
2818:         MOVEI TAC1,KILCM1               ;THIS IS THE PLACE TO START HIM
2819:         MOVE TAC,JBTPRV(J)              ;GET PRIV AGAIN
2820:         TLNN TAC,KILPRV                 ;SKIP IF HE HAS IT
2821:         MOVEI TAC1,JOBKL                ;ELSE NORMAL KJOB ROUTINE
2822:         PUSHJ P,MONJOB                  ;MAKE HIM A MONITOR JOB
2823: KILCM2: POP P,PROG                      ;SUPRISE
2824:         POP P,J                         ;IT'S ME AGAIN
2825:         POPJ P,                         ;DIDN'T SEE A THING
2826: 
2827: KILCM3: PUSHJ P,DLYCOM                  ;SET CMWB AND GET IN CORE IF NECESSARY
2828: KILCM4: POP P,PROG                      ;NOW LETS BE OURSELVES AGAIN
2829:         POP P,J
2830:         JRST DLYCM                      ;NOW DELAY US.
2831: 
2832: KILCM5: MOVE TAC,PRJPRG(TAC1)
2833:         MOVEM TAC,JOBNAM(TAC1)          ;NO ONE WILL BELIEVE THIS NAME.
2834: IFN FTSTAT,<PUSH P,J
2835:         MOVE J,TAC1
2836:         PUSHJ P,NAMSTT
2837:         POP P,J
2838: >
2839:         POPJ P,
2840: 
2841: NOTYRS: JSP TAC,ERRMES
2842:         ASCIZ /NOT ONE OF YOUR JOBS.
2843: /
2844: 
2845: ILLKIL: JSP TAC,CONMES
2846:         ASCIZ /USE "KJOB" TO LOG YOURSELF OFF.
2847: /
    CLKSER page# 0057 next  prev
2849: ;PRIVILEGED KILL ROUTINE, FLUSHES THINGS WITHOUT WAITING
2850: KILCM1: MOVEI   TAC1,ESTOP
2851:         JSP     TAC,MONSTR              ;MAKE ME SOME PDL
2852:         PUSHJ   P,RESETSEG              ;FLUSH HIS SEGMENT
2853:         PUSHJ   P,IOKILL                ;KILL ALL IO WITHOUT WAITING
2854:         PUSHJ   P,TTYFND                ;FIND TTY
2855:         PUSHJ   P,TSETBF                ;CLEAR IO
2856:         MOVSI IOS,TOIP
2857:         ANDCAB IOS,DEVIOS(DDB)          ;CLEAR TOIP SO ESTOP WON'T HANG
2858:         PUSHJ   P,KILSPW                ;KILL SPACEWAR
2859:         JRST    JOBKL1                  ;LET KJOB ROUTINE DO THE REST
    CLKSER page# 0058 next  prev
2861: KJOB2:  JUMPE   PROG,JOBKA      ;DOES JOB HAVE CORE?
2862:         JSP     TAC1,MONJOB     ;YES, SCHEDULE MONITOR JOB.
2863: JOBKL: MOVEI   TAC1,ESTOP2     ;ESTOP AT END OF PDL
2864:         JSP     TAC,MONSTR      ;SET UP ACS AND PDL LIST
2865: JOBKL1: PUSHJ   P,DSFLUSH       ;SET UP TO FLUSH SPECIAL DETACHED SEGMENTS
2866: 
2867: IFN FTDRD,<
2868:         CAMN    PROG,JBTADR(J)  ;THE FOLLOWING IS BROUGHT TO YOU BY THE DRD.
2869:         JRST    JOBKL2
2870:         PUSHAC
2871:         PUSHJ   P,DISMES
2872:         ASCIZ   /PROG CLOBBERED AT JOBKL1 /
2873:         PUSHJ   P,DISJOB
2874:         PUSHJ   P,DISCRLF
2875:         POPACS
2876: JOBKL2:
2877: >
2878:         PUSHJ   P,RESET         ;FINISH IO BEFORE DEASSIGNING
2879:         PUSHJ   P,DEASTY        ;WHILE WE STILL HAVE CORE, DEASSIGN DEVICES XCPT TTY
2880:         PUSHJ   P,JOB1          ;CALL RESET(AGAIN!), RELEASE CORE.
2881: 
2882: IFN FTDRD,<
2883:         SKIPN   JBTADR(J)       ;THE FOLLOWING IS MORE DRD CODE
2884:         JRST    JOBKA
2885:         PUSHACS
2886:         PUSHJ   P,DISMES
2887:         ASCIZ   /JBTADR NOT ZERO AT JOBKA-1 /
2888:         PUSHJ   P,DISJOB
2889:         PUSHJ   P,DISCRLF
2890:         POPACS
2891: >
2892: 
2893: JOBKA:
2894: IFE FTLOGIN,<
2895:         MOVE    TAC,TTIME(J)    ;TOTAL TIME
2896:         SUB     TAC,RTIME(J)    ;MINUS INCREMENTAL TIME
2897:         JUMPE   TAC,.+2         ;SKIP IF ZERO
2898:         PUSHJ   P,PRTIME        ;TYPE INCREMENTAL TIME
2899:         MOVE    TAC,TTIME(J)
2900:         PUSHJ   P,PRTIME        ;TYPE TOTAL TIME.
2901: >
2902: JOBKK:  PUSHJ   P,DEASTY        ;DEASSIGN ALL BUT TTY
2903:         PUSHJ   P,TTYERR        ;GET TTY FOR OUTPUT
2904:         PUSHJ   P,INLMES
2905:         ASCIZ   /KJOB
2906: /
2907:         PUSHJ P,PRPER
2908:         PUSHJ   P,TTYSTR
2909:         PUSHJ   P,TTYKIL        ;RETURN TTY TO VIRGIN STATE
2910:         SKIPE   AC1,JBTJL(J)    ;AND JOB PRIORITY HISTORY
2911:         PUSHJ   P,FSGIVE
2912:         SETZM   JBTJL(J)
2913:         SKIPE   AC1,JBTFS(J)    ; ANY SPARE FREE STORAGE?
2914:         PUSHJ   P,FSGIVE
2915:         SETZM   JBTFS(J)
2916:         PUSHJ P,TMPKIL          ;FLUSH ALL HIS TMPCOR FILES (IGNORING ALIAS)
2917:         PUSHJ   P,RELPDL        ;RELEASE THE PDL, IF ANY.
2918:                                 ;RETAIN USE OF PDL AS LONG AS WE'RE AT
2919:                                 ;UUO LEVEL OR CHANNEL 7
2920:         HLRZ    AC1,SAVSAI(J)
2921:         JUMPE   AC1,.+2
2922:         PUSHJ   P,FSGIVE        ;RETURN SWAP UUO AC SAVE BLK
2923:         SETZM   SAVSAI(J)
2924:         JRST    KSTOP           ;CLEAR JOB STATUS WORD AND STOP JOB
2925: 
2926: 
2927: ;ERROR IN COMMAND
2928: 
2929: 
2930: CERR:   JRST ERRMES
2931: 
2932: JOBKB:  SETZM -1(PDP)           ;CLEAR NOJOBN SO COMRET WILL PRINT MESSAGE
2933:         JRST LOGPLS             ;"LOGIN PLEASE"
    CLKSER page# 0059 next  prev
2935: ; "START L" OR "START" - START AT LOC. L OR STARTING ADDRESS
2936: ; "CSTART L" OR  "CSTART" - START AT LOC. L(TTY IN COMMAND MODE)
2937: 
2938: START:                                  ;SAME AS STARTC
2939: STARTC: PUSHJ P,SKIPSJ
2940:         CAIE TEM,"+"
2941:         CAIN TEM,"-"                    ;REQUESTING INCREMENT?
2942:         JRST STARTA                     ;YES, SCAN
2943:         PUSHJ P,OCTIN                   ;CONVERT POSSIBLE OCTAL NO ARG.
2944:         SKIPA TAC1,JOBSA(JDAT)          ;NO START ADR. SPECIFIED RETURN
2945:         JRST COMERA                     ;ILLEGAL CHARACTER
2946:         CAME TAC1,JOBSA(JDAT)           ;STARTUP ADDRESS TYPED?
2947:         PUSHJ P,CLRTPV                  ;YES, CLEAR TEMP PRIVILEGES
2948:         HRRZ TAC,TAC1                   ;GET STARTUP ADDR
2949:         TDZA TAC1,TAC1
2950: STARTB: HRRZ TAC,JOBSA(JDAT)
2951:         JUMPN TAC,STRTCK                ;ADD INCREMENT AND START
2952:         JSP TAC,ERRMES
2953:         ASCIZ /NO STARTUP ADDRESS!
2954: /
2955: 
2956: STARTA: CAIE TEM,"+"                    ;+?
2957:         JRST STARTE                     ;NO, MUST BE -
2958:         PUSHJ P,OCTINS                  ;YES, READ INC
2959:         SKIPA TAC1,[1]                  ;INVENT 1 FOR NO ARG
2960:         JRST COMERA
2961:         JRST STARTB
2962: 
2963: STARTE: PUSHJ P,OCTINS                  ;GET - INC
2964:         SKIPA TAC1,[1]                  ;INVENT 1 FOR NO ARG
2965:         JRST COMERA
2966:         MOVN TAC1,TAC1                  ;NOW NEGATE
2967:         JRST STARTB
2968: 
2969: ;"REENTER" - REENTER USER PROGRAM
2970: REENTE: PUSHJ P,SKIPSJ
2971:         CAIN TEM,"-"
2972:         JRST REENTM                     ;GET - INC
2973:         PUSHJ P,OCTIN
2974:         TDZA TAC1,TAC1                  ;0 FOR NO ARG
2975:         JRST COMERA                     ;ILL CHAR
2976: REENTN: HRRZ TAC,JOBREN(JDAT)
2977:         JUMPN TAC,STRTCK                ;ADD INCREMENT AND START
2978:         JSP TAC,ERRMES
2979:         ASCIZ /NO REENTER ADDRESS
2980: /
2981: 
2982: REENTM: PUSHJ P,OCTINS
2983:         SKIPA TAC1,[1]
2984:         JRST COMERA
2985:         MOVN TAC1,TAC1
2986:         JRST REENTN
2987: 
2988: STRTCK: JUMPE TAC1,.+2                  ;ANY INCREMENT?
2989:         PUSHJ P,CLRTPV                  ;YES, CLEAR TEMP PRIVILEGES
2990:         ADD TAC1,TAC                    ;ADD INCREMENT
2991:         JRST USTART                     ;NOW START IT UP
2992: 
2993: ; "HALT" OR "<CONTROL>C"
2994: ;SCANNER ROUTINES DUMMY UP STOP WHEN CONTROL C TYPED IN
2995: ;STOP MUST BE DELAYED IF THIS JOB IS SYSTEM TAPE USER
2996: ;AND SYSTEM TAPE IS ACTIVE. OTHERWISE, THE JOB WILL NOT BE
2997: ;STOPPED WHEN DONE USING THE SYSTEM TAPE.
2998: 
2999: 
3000: STOP:  JUMPE   ITEM,STOPB1
3001:         CAMN    ITEM,STUSER     ;IS THIS SYSTEM TAPE USER?
3002:         JRST    STOPA           ;YES
3003: IFN FTDISK,<
3004: 
3005:         PUSHJ   P,STOPCK        ;CAN THE JOB STOP?
3006:         JRST    MAKCNC          ;PUT BACK CONTROL C.
3007: >
3008:         PUSHJ   P,STOP1         ;STOP JOB
3009: STOPB:
3010: REPEAT 0,<
3011:         MOVSI   TAC,INTHAL      ;↑C USER INTERRUPT BIT
3012:         TDNN    TAC,JBTIEN(J)
3013:         JRST    STOPB1
3014:         IORM    TAC,JBTIRQ(J)   ;ENABLED, GIVE HIM THE INTERRUPT
3015:         SETOM   INTREQ(PID)     ;AS IF THE 6 WOULD EVER DO THIS
3016: >;END REPEAT 0.
3017: STOPB1: MOVSI   TAC,JACCT
3018:         ANDCAM  TAC,JBTSTS(J)   ;GOODBYE LOSER!
3019:         JSP     TAC,CONMES      ;PRINT "↑C CRLF CRLF PERIOD"
3020:         ASCIZ   /↑C
3021: /
3022:         POPJ    P,
3023: 
3024: STOPA:  POP     P,TAC1          ;DOES THE JOB HAVE ACTIVE DEVICES?
3025:         PUSHJ   P,ACTCHK
3026:         PUSHJ   P,ESTOP         ;NO, STOP THE JOB AND LET GO OF SYSTEM TAPE
3027:         MOVEI   TAC1,COMRET
3028:         PUSH    P,TAC1
3029:         JRST    STOPB
3030: 
3031: MAKCNC: MOVE    TAC1,LINSAV
3032:         MOVE    TAC1,TTYTAB(TAC1)
3033:         MOVEI   TAC,600
3034:         DPB     TAC,TITAKR(TAC1)
3035:         JRST    DLYCR1          ;DON'T REQUE, OR HE WON'T GET OUT OF THIS STATE!!!
    CLKSER page# 0060 next  prev
3037: ;CCONTINUE, CONTINUE, DDT
3038: 
3039: ; "CCONT" - CONTINUE EXECUTION(TTY REMAINS IN COMMAND MODE)
3040: ; "CONT" - CONTINUE EXECUTION FROM WHERE LEFT OFF
3041: 
3042: CONTC:                          ;SAME AS CONT
3043: CONT:   MOVSI   TAC1,JERR
3044:         TDNE    TAC1,JBTSTS(J)  ;IS JOB ERROR BIT SET?
3045:         JRST    NOCONT          ;YES, LOSE
3046:         MOVNI   TAC1,RUNQ       ;NO, REQUE TO RUN QUEUE
3047:         MOVEM   TAC1,JOBQUE(J)
3048:         JRST    REQUE
3049: 
3050: NOCONT: JSP TAC,ERRMES          ;YES, PRINT CANT CONTINUE
3051:         ASCIZ /CAN'T CONTINUE
3052: /
3053: 
3054: 
3055: ; "DDT" - START EXECUTION AT DDT IN USER AREA
3056: 
3057: DDTGO:  HRRZ    TAC1,JOBDDT(JDAT)       ;DDT STARTING ADR. IN JOB DATA AREA
3058:         JUMPN   TAC1,DDTG1              ;IS IT NON-ZERO? IF YES, STORE
3059:                                         ;OLD PC IN JOBOPC IN JOB DATA AREA
3060:                                         ;THEN START WITH PC IN USER MODE
3061:         JSP TAC,ERRMES                  ;ZERO PRINT "NO DDT"
3062:         ASCIZ /NO DDT
3063: /
3064: 
3065: ;KLUDGE TO MAKE SURE DDT MEMORY IS WRITEABLE
3066: DDTG1:  HLRZ    TAC,PROG
3067:         CAIG    TAC1,(TAC)
3068:         JRST    USTART                  ;ADR IN LOWER - GO AHEAD
3069:         MOVE    TAC1,JOBPC(PROG)
3070:         TLNN    TAC1,USRMOD
3071:         JRST    DDTG2
3072:         MOVSI   TAC,JOBDAC(PROG)        ;MAKE SURE ACS ARE IN RIGHT PLACE
3073:         HRRI    TAC,(PROG)
3074:         BLT     TAC,17(PROG)
3075: DDTG2:  JSP     TAC1,MONJOB             ;GET TO UUO LEVEL
3076:         JSP     TAC,MONSTR
3077:         PUSHJ   P,UNPURE                ;TRY TO UNPURIFY UPPER
3078:         JRST    DDTPUR
3079: DDTG3:  HRRZ    TAC,JOBDDT(PROG)        ;WHERE TO GO
3080:         HLL     TAC,JOBOPC(PROG)        ;WITH HIS OLD FLAGS
3081:         TLO     TAC,USRMOD              ;DEFINITELY IN USER MODE
3082:         TLZ     TAC,4037                ;CLEAR IOT-USER AND @() BITS
3083:         MOVEM   TAC,UUOPC(J)
3084:         JRST    USRXIT                  ;"RETURN" FROM THIS "UUO"
3085: 
3086: DDTPUR: MOVE    J,JOB(PID)              ;J WAS CLOBBERED BY UNPURE.
3087:         PUSHJ   P,TTYERP
3088:         PUSHJ   P,INLMES
3089:         ASCIZ   /COULDN'T UNPURIFY UPPER. CONTINUE TO TRY ANYWAY./
3090:         PUSHJ   P,PRCRCC
3091:         PUSHJ   P,TTYSTC                ;NOW, FORCE TTY TO TYPE STUFF.
3092:         PUSHJ   P,SETSTP                ;MAKE US STOP SOON
3093:         JRST    DDTG3
    CLKSER page# 0061 next  prev
3095: ;SETUWP, CLRUWP, ENABLE, DISABLE
3096: SETWPS: PUSH P,[-1,,0]                  ;NO PRO BITS YET
3097:         CAIA
3098: CLRWPS: PUSH P,[0]                      ;NO PRO BITS YET
3099:         PUSHJ P,OCTIN
3100:         JRST NOSPRO                     ;NO SET PRO
3101:         JRST [  POP P,(P)
3102:                 JRST COMERA]
3103:         CAILE TAC1,777                  ;LEGAL?
3104:         JRST ILLPRO
3105:         TRO TAC1,400000
3106:         HRRM TAC1,(P)
3107: NOSPRO: PUSH P,J
3108:         LDB J,PSEGN
3109:         JUMPE J,NXSEG
3110:         PUSHJ P,ACCESS
3111:         JRST WPSEG
3112:         JRST WPSEG
3113:         HRRZ TAC1,-1(P)                 ;GET PRO BITS
3114:         TRNN TAC1,400000                ;IS HE REQUESTING BIT SETTINGS?
3115:         JRST NOSPR1                     ;NO
3116:         MOVE TAC1,(P)                   ;JOB #
3117:         MOVE TAC1,JBTPRV(TAC1)
3118:         TLNN TAC1,SEGPRV                ;DOES HE HAVE PRIV?
3119:         TRNN TAC,400                    ;NO, CHECK PROTECTION PROTECTION
3120:         CAIA                            ;OKAY TO DIDDLE
3121:         JRST WPSEG                      ;LOSE
3122:         HRRZ TAC1,-1(P)                 ;GET BITS AGAIN
3123:         ANDI TAC1,377                   ;DON'T LET HIM SET UNPURIFIED BIT
3124:         DPB TAC1,[POINT 9,JOBCRD(J),8]
3125: NOSPR1: MOVSI TAC,JWP
3126:         SKIPGE -1(P)
3127:         IORB TAC,JBTSTS(J)
3128:         SKIPL -1(P)
3129:         ANDCAB TAC,JBTSTS(J)
3130:         POP P,-1(P)                     ;MOVE J BACK ONTO FLAG
3131:         HLRZ TAC1,JBTADR(J)             ;GET SEGMENT PROT
3132:         TLNE TAC,JWP
3133:         TLO TAC1,400000                 ;SET WP BIT IF JWP SET
3134:         MOVE TAC,J                      ;SAVE J HERE
3135:         MOVEI J,JOBN-1                  ;PREPARE TO SCAN ALL JOBS
3136: SETRLC: LDB AC1,PSEGN
3137:         CAMN AC1,TAC                    ;USING THIS SEGMENT?
3138:         SKIPN PROG,JBTADR(J)            ;YES, IS JOBRL2 AVAILABLE?
3139:         CAIA                            ;NO
3140:         MOVEM TAC1,JOBRL2(PROG)         ;STORE NEW JOBRL2
3141:         SOJG J,SETRLC
3142:         POP P,J
3143:         POPJ P,
3144: 
3145: NXSEG:  POP P,J
3146:         POP P,(P)
3147:         JSP TAC,ERRMES
3148:         ASCIZ /NO UPPER SEGMENT!
3149: /
3150: 
3151: WPSEG:  POP P,J
3152:         POP P,(P)
3153:         JSP TAC,ERRMES
3154:         ASCIZ /SORRY, PROTECTION FAILURE!
3155: /
3156: 
3157: ILLPRO: POP P,(P)
3158:         JSP TAC,ERRMES
3159:         ASCIZ /ILLEGAL PROTECTION CODE!
3160: /
3161: 
3162: DISABL: PUSHJ P,PRVSET                  ;GET BIT INTO TAC
3163:         JRST NXPRV                      ;NO SUCH PRIVILEGE
3164:         HRLOI TAC,-1-LUPPRV             ;CR TYPED, CLEAR ALL BITS (EXCEPT TNTPRV)
3165:         JFCL                            ;NOT LEGAL PRIV FOR THIS USER (OK TO CLEAR)
3166:         ANDCAM TAC,JBTPRV(J)
3167:         POPJ P,
3168: 
3169: ENABLE: PUSHJ P,PRVSET
3170:         JRST NXPRV
3171:         SKIPA TAC,JB2PRV(J)             ;CR, COPY PRIVILEGES FROM PASSIVE
3172:         JRST ILLPRV                     ;NOT LEGAL FOR THIS USER
3173:         IORM TAC,JBTPRV(J)
3174:         POPJ P,
3175: 
3176: NXPRV:  JSP TAC,ERRMES
3177:         ASCIZ /NO SUCH PRIVILEGE!
3178: /
3179: 
3180: ILLPRV: JSP TAC,ERRMES
3181:         ASCIZ /SORRY, YOU CAN'T HAVE THAT PRIVILEGE!
3182: /
3183: 
3184: 
3185: DEFINE XLPRIV(NAM,VAL)< 'NAM',,VAL>
3186: DEFINE XRPRIV(NAM,VAL)<>
3187: 
3188: LFTTAB:PRIVS
3189: LFTLEN←←.-LFTTAB
3190: 
3191: 
3192: DEFINE XLPRIV(NAM,VAL)<>
3193: DEFINE XRPRIV(NAM,VAL)<'NAM',,VAL>
3194: 
3195: RHTTAB:PRIVS
3196: RHTLEN←←.-RHTTAB
3197: 
3198: 
3199: PRVSET: PUSHJ P,CTEXT1
3200:         JUMPE TAC1,CPOPJ1               ;CR OR DELIM TYPED
3201: IFG LFTLEN,<
3202:         MOVSI TAC,-LFTLEN               ;LENGTH OF LEFT TABLE
3203: FNDLFT: HLLZ AC1,LFTTAB(TAC)
3204:         CAMN AC1,TAC1
3205:         JRST ISLFT
3206:         AOBJN TAC,FNDLFT
3207: >;LFTLEN
3208: IFG RHTLEN,<
3209:         MOVSI TAC,-RHTLEN
3210: FNDRHT: HLLZ AC1,RHTTAB(TAC)
3211:         CAMN AC1,TAC1
3212:         JRST ISRHT
3213:         AOBJN TAC,FNDRHT
3214: >;FNDRHT
3215:         POPJ P,                         ;NO SUCH PRIVILEGE
3216: 
3217: ISLFT:  HRLZ TAC,LFTTAB(TAC)            ;LEFT HALF BIT
3218:         CAIA
3219: ISRHT:  HRRZ TAC,RHTTAB(TAC)            ;RIGHT HALF BIT
3220:         AOS (P)
3221:         AOS (P)                         ;AT LEAST 2 SKIPS
3222:         TDNE TAC,[RSPRVS]               ;IS HE REQUESTING A RESTRICTED PRIVILEGE?
3223:         POPJ P,                         ;YES, FLUSH
3224:         MOVE AC1,JB2PRV(J)              ;GET PASSIVE PRIVILEGES
3225:         TLNN AC1,PRIPRV                 ;IF HE HAS PRIV PRIV, ALL IS OK
3226:         TDNE TAC,AC1                    ;OR IF THE PRIV HE WANTS IS IN PASSIVE TABLE
3227:         AOS (P)                         ;SKIP IF PRIV OK
3228:         POPJ P,
    CLKSER page# 0062 next  prev
3230: ; "CORE  #" - ASSIGNS #*1024 WORDS OF CORE TO JOB
3231: ;   "CORE" WITH NO ARG. WILL PRINT NO OF FREE BLOCKS LEFT
3232: ;       WITHOUT AFFECTING CURRENT ASSIGNMENT OF CORE
3233: 
3234: 
3235: 
3236: CORE:   PUSHJ   P,DECIN         ;GET NO. OF 1K BLOCKS
3237:         JRST    COR4            ;NO ARG. SPECIFIED, JUST TYPE FREE BLOCK LEFT
3238:         JRST    COMERA          ;ILLEGAL DECIMAL CHARACTER RETURN
3239: IFN FTLOGIN,<
3240:         MOVE    TAC,JBTSTS(J)   ;GET JOB STATUS WORD
3241:         TLNN    TAC,JLOG        ;IS JOB LOGGED IN?
3242:         JRST    LOGPLS          ;NO, TYPE OUT MESSAGE
3243: >
3244:         PUSHJ   P,CLRTPV        ;CLEAR TEMPORARY PRIVILEGES
3245: IFN FTSWAP,<
3246:         MOVE    AC1,SWAPLIMIT   ;GET THE SWAPLIMIT
3247:         LSH     AC1,-12         ;CONVERT SWAPLIMIT TO K
3248:         CAMLE   TAC1,AC1        ;TOO BIG?
3249:         JRST    CORFX1          ;YES. TELL HIM SO.
3250:         TLNN    TAC,SWP         ;IS HE SWAPPED OUT?
3251:         JRST    COR3            ;NO. CONTINUE
3252:         JUMPN   PROG,DLYCR1     ;DELAY UNTIL HE IS IN CORE
3253:         SKIPN   TAC,TAC1        ;DEC 3.16
3254:         JRST    CORX            ;DEC 3.16
3255:         SOS     (PDP)           ;DEC 3.16
3256:         JRST    CORE0K          ;DEC 3.16
3257: 
3258: 
3259: COR3:>
3260:         JUMPE   TAC1,COR0       ;RELEASE DEVICES IF ASKING FOR 0 CORE
3261:         MOVE    TAC,TAC1        
3262:         LSH     TAC,12          ;CONVERT 1K BLOCKS TO WORDS
3263:         SUBI    TAC,1           ;HIGHEST REL. LOC.
3264:         PUSH    P,JBTADR(J)     ;SAVE OLD CORE ASSIGNMENT
3265:         LDB     TAC1,PSEGN      ;SEE IF HE HAS AN UPPER
3266:         SKIPE   TAC1
3267:         PUSHJ   P,CORSGT        ;YES, GET ITS SIZE INTO TAC1
3268:         ADD     TAC1,TAC        ;ADD LOWER SIZE + UPPER SIZE
3269:         CAMLE   TAC1,CORMAX     ;WILL IT FIT?
3270:         JRST    CORFX           ;NO
3271:         PUSHJ   P,CORE0         ;TRY TO ASSIGN CORE
3272:         JRST    CORFX           ;CAN'T DO IT
3273:         POP     P,AC1           ;GET BACK OLD CORE ASSIGNMENT
3274:         SKIPE   AC1             ;IF NO CORE ASSIGNED PREVIOUSLY
3275: CORX1:  POPJ    P,DLYCOR-1      ;DEC 3.16 
3276:         PUSHJ   P,CLRJOB
3277:         SETZM   JOBSA(PROG)
3278:         JRST    CORX1
3279: 
3280: CORFX:  POP     P,(P)           ;POP OFF OLD CORE ASSIGNMENT
3281: CORFX1: MOVE    DDB,-2(P)       ;GET TTY DDB BACK
3282:         JSP     TAC,ERRMES
3283:         ASCIZ   /NOT ENOUGH CORE!
3284: /
    CLKSER page# 0063 next  prev
3286: COR4:   MOVSI   TAC,NOINCK      ;DON'T INITIALIZE A JOB
3287:         IORM    TAC,-1(PDP)
3288:         MOVE    DEVDAT,-2(P)    ;RESTORE TTY DDB
3289: IFE FTSWAP,<
3290:         MOVE    TAC,CORTAL      ;NO. OF FREE 1K BLOCKS
3291:         PUSHJ   P,RADX10        ;PRINT NO. OF FREE 1K BLOCKS LEFT
3292:         PUSHJ   P,INLMES
3293: CORMES: ASCIZ   /K CORE LEFT
3294: /
3295:         POPJ    P,
3296: >
3297: IFN FTSWAP,<
3298: IFN FTLOGIN,<
3299:         MOVE    TAC,JBTSTS(J)   ;GET JOB STATUS WORD
3300:         TLNN    TAC,JLOG        ;IS JOB LOGGED IN?
3301:         JRST    COR2.1          ;NOT LOGGED IN. HE HAS NO CORE.
3302: >
3303:         MOVEI   TAC1,(J)        ;GET JOB NUMBER
3304:         PUSHJ   P,CORSGT        ;GET CORE SIZE IN WORDS
3305:         LSH     TAC1,-12        ;DIVIDE TO GET K
3306:         MOVEI   TAC,(TAC1)
3307:         PUSHJ   P,RADX10
3308:         PUSHJ   P,INLMES
3309:         ASCIZ   /K IS YOUR JOB SIZE.
3310: /
3311:         LDB     TAC1,PSEGN
3312:         JUMPE   TAC1,COR2.1
3313:         PUSHJ   P,CORSGT        ;GET SIZE OF UPPER IN WORDS IN TAC1
3314:         LSH     TAC1,-12        ;CONVERT TO K
3315:         MOVEI   TAC,(TAC1)
3316:         PUSHJ   P,RADX10
3317:         PUSHJ   P,INLMES
3318:         ASCIZ   /K IS YOUR UPPER.
3319: /
3320: COR2.1: MOVE    TAC,CORMAX              ;LOAD AVAIL CORE ;REG
3321:         CAMLE   TAC,SWAPLIMIT           ;BIGGER THAN SWAPLIMIT?
3322:         MOVE    TAC,SWAPLIMIT           ;YES, PRINT IT INSTEAD
3323:         LSH     TAC,-12                 ;CONVERT TO K
3324:         PUSHJ   P,RADX10                ;WRITE
3325:         PUSHJ   P,INLMES
3326:         ASCIZ   /K MAX.
3327: /
3328:         MOVE    TAC,CORMAX              ;GET MAX AGAIN
3329:         CAMG    TAC,SWAPLIMIT           ;BIGGER THAN MAX?
3330:         POPJ    P,
3331:         LSH     TAC,-12
3332:         PUSHJ   P,RADX10                ;YES, PRINT IT ALSO
3333:         PUSHJ   P,INLMES
3334:         ASCIZ   /K USER CORE.
3335: /
3336:         POPJ    P,
3337: >
3338: LOGPLS:JSP TAC,ERRMES
3339:         ASCIZ /LOGIN PLEASE
3340: /
    CLKSER page# 0064 next  prev
3342: PRJOB:  PUSHJ P,INLMES
3343:         ASCIZ /JOB /
3344:         MOVE TAC,J
3345:         PUSHJ P,RADX10
3346:         PUSHJ P,PRSPC
3347: PRCONF: MOVEI TAC,CONFIG
3348:         JRST CONMES
3349: 
3350: ;HELLO                          ;JS, REST OF PAGE
3351: HELLO:  PUSHJ   P,PRCONF        ;TELL HIM WHAT FLAVOR SYSTEM WE ARE!
3352:         JRST    CRLF            ;TYPE CRLF
3353: 
3354: IFN FTLOGIN,<
3355: ;AUTOMATIC LOGIN AFTER DISK REFRESH OR WHEN REFLAG SET  ;DEC 3.16, REST OF PAGE
3356: 
3357: LOGREF: MOVEM   TAC,PRJPRG(J)           ;PJ,PG NOS IN REFLAG
3358:         MOVSI   TAC,JLOG
3359:         IORM    TAC,JBTSTS(J)           ;LOG HIM IN.
3360:         MOVSI   TAC,LUPPRV!PRIPRV       ;SET JOB PRIVILEGES
3361:         MOVEM   TAC,JBTPRV(J)
3362:         MOVEM   TAC,JB2PRV(J)
3363:         SETZM   -1(P)                   ;CLEAR ALL FLAGS FOR COMRET.
3364:         SETZM   REFLAG                  ;ONLY ONCE.
3365:         POPJ    P,
3366: >
    CLKSER page# 0065 next  prev
3368: ;"HELP" -HELP COMMAND
3369: 
3370: 
3371: IFN FTLOGIN,<   ;DEC 3.16
3372: HELP1:  MOVE    TAC,HELPPP
3373:         TLNE    AC1,JLOG
3374:         POPJ    P,
3375:         PUSHJ   P,ALOGIN
3376:         MOVSI   TAC1,LUPPRV             ;GIVE 100,100 THE LOCAL USER PRIV
3377:         IORM    TAC1,JBTPRV(J)          ;BECAUSE HE CAN'T HARM US
3378:         JRST    SETLOG                  ;AND SET-UP LOGIN STUFF
3379: >
3380: 
3381: HELP:
3382: IFN FTLOGIN,<
3383:         PUSHJ PDP,HELP1
3384: >
3385:         PUSH P,['HELP  ']
3386:         JRST ARCOM
3387: 
3388: WHECOM:
3389: IFN FTLOGIN,<
3390:         PUSHJ P,HELP1
3391: >
3392:         PUSH P,['WHERE ']
3393:         JRST ARCOM
3394: 
3395: WHOCOM:
3396: IFN FTLOGIN,<
3397:         PUSHJ P,HELP1
3398: >
3399:         PUSH P,['WHO   ']
3400:         JRST ARCOM
3401: 
3402: FIXIML:
3403: IFN FTLOGIN,<
3404:         PUSHJ P,HELP1
3405: >
3406:         PUSH P,['FIXIML']
3407:         JRST ARCOM
3408: 
3409: FNDCOM:
3410: IFN FTLOGIN,<
3411:         PUSHJ   P,HELP1
3412: >
3413:         PUSH    P,['FIND  ']
3414:         JRST    ARCOM
    CLKSER page# 0066 next  prev
3416: ;ALOGIN, SETTPV, CLRTPV
3417: 
3418: ALOGIN:
3419: IFN FTLOGIN,<   
3420:                 MOVEM   TAC,PRJPRG(J)
3421: IFN FTDISK,<
3422:                 SETZM   JBTUFD(J)
3423: IFN FTDSKPPN,<  SETZM   DSKPPN(J)       ;INTIALIZE DISK ALIAS PPN>
3424:         >
3425:                 SETZM   JBTKCJ(J)
3426:                 MOVSI   TAC,JLOG
3427:                 ANDCAM  TAC,JBTSTS(J)
3428: >
3429: IFN FTSWAP,<
3430: ALOGN1: PUSHJ   P,TTYATI        ;MAKE SURE TTY IS ATTACHED IN CASE
3431:                                 ;THIS COMMAND MUST BE DELAYED
3432:                                 ;BECAUSE NO CORE YET.
3433:         JFCL
3434: >
3435:         POPJ    P,
3436: 
3437: SETTPV: ANDCM   TAC,JBTPRV(J)   ;DON'T NEED ANY TEMPORARY PRIVS HE REALLY HAS
3438:         IORM    TAC,JBTPRV(J)   ;GIVE HIM THE TEMP PRIVS
3439:         IORM    TAC,JBTTPV(J)   ;REMEMBER TEMP PRIVILEGES WE ARE GIVING HIM
3440:         POPJ    P,
3441: 
3442: CLRTPV: EXCH    TAC,JBTTPV(J)   ;SAVE TAC, PICK UP TEMP PRIVILEGES
3443:         ANDCAM  TAC,JBTPRV(J)   ;TURN OFF TEMP PRIVS
3444:         MOVEI   TAC,0
3445:         EXCH    TAC,JBTTPV(J)   ;RESTORE TAC, NO TEMP PRIVILEGES NOW
3446:         POPJ    P,
    CLKSER page# 0067 next  prev
3448: ;"LOGIN" - LOGIN COMMAND
3449: 
3450: IFN FTLOGIN,<
3451: 
3452: LOGDET: JSP     TAC,ERRMES
3453:         ASCIZ   /PLEASE KJOB OR DETACH
3454: /
3455: 
3456: CLOGIN: TLNE    AC1,JLOG        ;IS HE LOGGED IN?
3457:         JRST    LOGDET          ;YES. FORCE LOGOUT FIRST
3458:         SKIPE   TAC,REFLAG      ;DEC 3.16
3459:         JRST    LOGREF          ;DEC 3.16
3460:         JRST    .+2             ;(TAC HAS A ZERO)
3461: CXLOGI: MOVEI   TAC,1
3462:         HRRM    TAC,SAVSAI(J)   ;SET STARTING OFFSET.
3463:         MOVE    TAC,DUMPPN      ;SET PRJPRG TO DMPPPN
3464:         PUSHJ   P,ALOGIN        ;AUTOMATIC LOGIN
3465:         MOVSI   TAC,JACCT       ;FLAG ACCOUNTING PROGRAM RUNNING
3466:         IORM    TAC,JBTSTS(J)
3467:         PUSHJ   P,SKPBRK
3468:         MOVE    TAC,[SIXBIT /LOGIN/]    ;LOGIN FILE NAME.
3469:         MOVEM   TAC,JOBNAM(J)   ;STORE FILE NAME
3470: IFN FTSTAT,<PUSHJ P,NAMSTT>
3471:         MOVSI   TAC1,'DSK'      ;READ FROM DSK, DMPPPN AREA.
3472:         JRST    RUNCO2
3473: >
3474: 
3475: ;ONE OF THE RPG COMMANDS -- COMPILE, DEBUG, ECT
3476: 
3477: RPGCOM: PUSH PDP,[SIXBIT /RPG/]
3478:         JRST ARCOM
3479: 
3480: ETCOM:  PUSH P,['E     ']
3481:         JRST ARCOM
3482: 
3483: DSCCOM: PUSH PDP,[SIXBIT /DART  /]
3484:         JRST ARCOM
3485: 
3486: CPYCOM: PUSH PDP,[SIXBIT /COPY/]
3487:         JRST ARCOM
3488: 
3489: MAICOM: PUSH P,[SIXBIT/MAIL/]
3490:         JRST ARCOM
3491: 
3492: OBLCOM: PUSH    P,['FORGET']
3493:         JRST    ARCOM
3494: 
3495: RCVCOM: PUSH    P,[SIXBIT /RCV/]
3496: IFN FTLOGIN,<
3497:         PUSHJ   P,HELP1
3498: >
3499:         JRST    ARCOM
3500: 
3501: NSCOM:  PUSH    P,[SIXBIT /NS/]
3502: NSCOM1: MOVE    TAC,JBTPRV(J)   ;GET USER'S REAL PRIVS
3503:         TLNN    TAC,LUPPRV      ;IS HE LOCAL?
3504:         JRST    NSCOM2          ;NOPE, FLUSH HIM
3505:         MOVSI   TAC,REAPRV
3506:         PUSHJ   P,SETTPV        ;SET TEMPORARY PRIVILEGES
3507:         PUSH    P,[SIXBIT /  1  2/]
3508:         JRST    ARPCOM
3509: 
3510: NSCOM2: POP     P,TAC
3511:         JRST    COMERR          ;PRETEND IGNORANCE
3512: 
3513: UDPCOM: PUSH    P,[SIXBIT /UDPUFD/]
3514:         MOVE    TAC,JBTPRV(J)   ;GET USER'S REAL PRIVS
3515:         TLNN    TAC,LUPPRV      ;IS HE LOCAL?
3516:         JRST    NSCOM2          ;NOPE, FLUSH HIM
3517:         MOVSI   TAC,INFPRV!DAWPRV!WRTPRV!PROPRV ;BOY IS THIS A HAIRY PROGRAM
3518:         PUSHJ   P,SETTPV        ;SET TEMPORARY PRIVILEGES
3519:         PUSH    P,[SIXBIT /  1  2/]
3520:         JRST    ARPCOM
3521: 
3522: HOTCOM: PUSH    P,[SIXBIT /HOT/]
3523:         JRST    NSCOM1
3524: 
3525: SPLCOM:
3526: IFN FTLOGIN,<
3527:         PUSHJ   P,HELP1
3528: >
3529:         PUSH    P,[SIXBIT /SPOOL/]
3530:         JRST    ARCOM
3531: 
3532: FINGER:
3533: IFN FTLOGIN,<
3534:         PUSHJ   P,HELP1
3535: >
3536:         PUSH    P,[SIXBIT /FINGER/]
3537:         JRST    ARCOM
3538: 
3539: LSPCOM: PUSH    P,[SIXBIT /LISP/]
3540:         JRST    ARCOM
3541: 
3542: DOCOM:  PUSH    P,[SIXBIT /DO/]
3543:         JRST    ARCOM
3544: 
3545: ZERCOM: PUSH    P,[SIXBIT /ZERO/]
3546:         JRST    ARCOM
3547: 
3548: XERCOM: PUSH    P,[SIXBIT /XEROX/]
3549:         JRST    ARCOM
3550: 
3551: TSTCOM: PUSH    P,[SIXBIT /TEST/]
3552:         JRST    ARCOM
3553: 
3554: RSLCOM: PUSH    P,[SIXBIT /RSL/]
3555:         JRST    ARCOM
3556: 
3557: TNCOM:  PUSH    P,[SIXBIT /T/]
3558:         JRST    ARCOM
3559: 
3560: FTPCOM: PUSH    P,[SIXBIT /FTP/]
3561:         JRST    ARCOM
3562: 
3563: DILCOM: PUSH    P,[SIXBIT /DIAL/]
3564:         JRST    ARCOM
    CLKSER page# 0068 next  prev
3566: ;R, RUN, SAVE, SSAVE, GET COMMANDS
3567: 
3568: ;ARCOM:  CALL WITH JOBNAM STACKED.  RUN IT FROM SYS:
3569: ;AXCOM:  SAME AS ARCOM, EXCEPT JOB STARTS AT C(JOBSA)+1
3570: 
3571: ARCOM:  TDZA    TAC,TAC         ;AUTOMATIC RUN COMMAND
3572: AXCOM:  MOVEI   TAC,1           ;START WITH OFFSET=1
3573:         PUSHJ   P,SKPBRK
3574: ARCOM1: HRRM    TAC,SAVSAI(J)   ;SET STARTUP OFFSET
3575:         POP     P,JOBNAM(J)     ;STORE FILE NAME
3576: IFN FTSTAT,<    PUSHJ   P,NAMSTT>
3577:         MOVSI   TAC1,'SYS'      ;READ FROM SYSTEM DEVICE
3578:         JRST    RUNCO2
3579: 
3580: ;START UP WITH DOUBLE-SKIP C(JOBSA)+2, TTY POINTS TO THE REST OF LINE
3581: AXXCOM: MOVSI   TAC,NOSKPB      ;DOUBLE-SKIP ENTRY
3582:         IORM    TAC,-2(P)       ;TELL COMRET NOT TO CALL SKPBRK (JOBNAME STILL ON STACK)
3583:         MOVEI   TAC,2           ;SET FOR DOUBLE-SKIP ENTRY
3584:         JRST    ARCOM1
3585: 
3586: ;ARPCOM: CALL WITH JOBNAM STACKED, AND PPN STACKED TOO!
3587: 
3588: ARPCOM: HLLZS   SAVSAI(J)       ;ZERO STARTING OFFSET
3589:         POP     P,JOBPPN(J)     ;SETUP SGSET KLUDGE
3590:         PUSHJ   P,SKPBRK        ;SKIP TO END OF LINE
3591:         POP     P,JOBNAM(J)
3592: IFN FTSTAT,<    PUSHJ   P,NAMSTT>
3593:         MOVSI   TAC1,'DSK'      ;READ FROM DSK
3594:         JRST    RUNCO4
3595: 
3596: ;"R CUSPNAME CORE" - DOES "RUN SYS:CUSPNAME"
3597: RCOM:   PUSH    P,[0]           ;ZERO OUT PROGRAM NAME
3598:         MOVEI   TAC,0
3599:         JRST    ARCOM1
3600: 
3601: ;"RUN DEVICE:FILE[PROJ.,PROG.] (CORE)"
3602: ;DOES A CORE,GET,START ALL IN ONE
3603: ;IF CORE ARG IS MISSING, SIZE IN DIRECTORY IS USED
3604: 
3605: 
3606: RUNCOM: PUSHJ   P,CTEXT1        ;GET DEVICE NAME FROM COMMAND STRING
3607:         SETZM   JOBNAM(J)       ;CLEAR OUT OLD JOB NAME
3608: IFN FTSTAT,<    PUSHJ   P,NAMSTT>
3609:         HLLZS   SAVSAI(J)       ;CLEAR STARTUP INCREMENT
3610: RUNCO2: SETZM   JOBPPN(J)       ;DISABLE JOBPPN KLUGE FOR SGSET
3611: RUNCO4: MOVEI   IOS,RUNJOB
3612: RUNCM:  PUSH    P,IOS           ;SAVE DISPATCH
3613:         JUMPN   PROG,RUNCO1     ;NO. DOES JOB HAVE CORE?
3614:         PUSH    P,TAC1          ;SAVE DEVICE NAME
3615:         MOVEI   TAC,ASSPRG      ;CLEAR TTY "ASSIGNED BY PROGRAM" BIT
3616:         ANDCAM  TAC,DEVMOD(DDB)
3617:         MOVEI   TAC,JOBDA       ;REQUEST JUST ENOUGH CORE FOR A JOB DATA AREA
3618:         PUSHJ   P,CORE0         ;IF OLD CORE(DEVICE ASSIGNMENTS RETAINED
3619:         JFCL                    ;NO ROOM(PROG=0) OR ACTIVE IO (PROG NON ZERO)
3620:         POP     P,TAC1          ;RESTORE DEVICE NAME
3621: RUNCO1: POP     P,IOS           ;ADR. OF MONITOR JOB
3622: IFE FTSWAP,<    JUMPN   PROG,RUNCO3     ;AND SCAN REST OF ARG. IF CORE ASSIGNED
3623:                 JSP     TAC,ERRMES
3624:                 ASCIZ   /CORE IS FULL
3625: /
3626: RUNCO3:>
3627: IFN FTSWAP,<    JUMPE   PROG,DLYCOR     ;DELAY IF ON DISK >
3628:         MOVEM   UUO,COMWRD(PROG)        ;PUT COMMAND IN AC FOR PROG TO SEE
3629:         MOVEM   TEM,CHRWRD(PROG)        ;ALSO DELIMITER CHAR
3630:         SKIPN   AC2,JOBPPN(J)           ;SPECIAL PPN HACK?
3631:         JRST    SGSET                   ;NO
3632:         JRST    SGSET0                  ;YES. SPECIAL ENTRY
3633: 
3634: ;"GET DEVICE:FILE-NAME[PROJ.,PROG.] CORE" - SETS UP JOB AREA FROM RETREIVABLE
3635: ;DEVICE AND ASSIGNS CORE.
3636: 
3637: 
3638: GET:    MOVEI   IOS,GETJOB      ;SETUP TO RUN GETJOB
3639:         PUSHJ   P,CTEXT1        ;GET DEVICE NAME
3640:         SETZM   JOBNAM(J)       ;CLEAR JOB NAME
3641:         SETZM   JOBPPN(J)       ;DISABLE JOBPPN KLUGE FOR SGSET
3642: IFN FTSTAT,<    PUSHJ   P,NAMSTT>
3643:         JRST    RUNCM
3644: 
3645: 
3646: ;"SAVE FILE-NAME[PROJ.,PROG.] CORE" - SAVES JOB AREA ON RETRIEVABLE DEVICE
3647: ;ONLY A SAVE OR A GET IN PROGRESS FOR EACH JOB
3648: ;NO ATTEMPT IS MADE TO SAVE DEVICE ASSIGNMENTS, AC'S, OR PC
3649: 
3650: 
3651: SSAVE:  TROA    IOS,SSAVJB      ;SAVE UPPER ALSO (IOS CLEARED BEFORE DISPATCH)
3652: SAVE:   MOVEI   IOS,SAVJOB      ;SETUP TO RUN SAVJOB 
3653:         PUSHJ   P,CTEXT1        ;GET THE FIRST COMMAND ARGUMENT (DEV OR FILENAME)
3654:         SETZM   JOBNAM(J)       ;CLEAR JOB NAME.
3655: IFN FTSTAT,<    PUSHJ   P,NAMSTT>
3656:         JRST    SGSET           ;SCAN THE REST OF THE ARGUMENTS
    CLKSER page# 0069 next  prev
3658: ; "ASSIGN DEV:NAME" - ASSIGN DEVICE TO JOB AND GIVE IT LOGICAL NAME
3659: 
3660: ASSIGN: MOVEI AC1,0                     ;START WITH NO ATTRIBUTES
3661: ASSPP9: PUSHJ P,CTEXT1                  ;GET FIRST ARGUMENT
3662:         JUMPE TAC1,NOTENF               ;NO ARGUMENT TYPED IF 0
3663:         MOVEI AC2,0
3664:         MOVSI TAC,770000
3665: ASSPP1: TDNN TAC,TAC1
3666:         JRST ASSPP2
3667:         IORM TAC,AC2                    ;MAKE MASK FOR NUMBER OF CHARACTERS TYPED
3668:         LSH TAC,-6
3669:         JUMPN TAC,ASSPP1
3670: ASSPP2: MOVSI TAC,-NASATT
3671: ASSPP3: CAMN TAC1,ASATTT(TAC)
3672:         JRST ASSPP0                     ;EXACT MATCH.  GET BITS AND LOOP
3673:         MOVE AC3,ASATTT(TAC)            ;GET NAME OF ATTRIBUTE
3674:         AND AC3,AC2                     ;AND WITH MASK
3675:         CAMN TAC1,AC3
3676:         TLON AC1,400000(TAC)
3677:         AOBJN TAC,ASSPP3
3678:         JUMPL TAC,ASSPPX                ;AOBJN DIDN'T FALL THROUGH (TOO MANY MATCHES)
3679:         JUMPGE AC1,ASSPPX               ;IF SIGN BIT OFF THERE WERE NO MATCHES
3680:         LDB TAC,[POINT 17,AC1,17]       ;GET INDEX OF MATCHING ENTRY
3681: ASSPP0: TDNE AC1,ASATBB(TAC)            ;CHECK FOR EXCLUDED BITS
3682:         JRST COMERR                     ;NAUGHTY NAUGHTY
3683:         IOR AC1,ASATTB(TAC)             ;OK, TURN ON NEW BIT
3684:         MOVEI AC1,(AC1)                 ;FLUSH CRUFT IN LH
3685:         JRST ASSPP9
3686: 
3687: PUBBIT←←1
3688: PRIBIT←←2
3689: OLDBIT←←4
3690: 
3691: ASATTT: 'PUBLIC'
3692:         'PRIVAT'
3693:         'OLD   '
3694: NASATT←←.-ASATTT
3695: 
3696: ASATTB: PUBBIT
3697:         PRIBIT
3698:         OLDBIT
3699: IFN .-ASATTB-NASATT,<PRINTS /SOMEONE CAN'T COUNT AT ASATTB
3700: />
3701: 
3702: ASATBB: PRIBIT!OLDBIT                   ;TABLE OF BITS NOT ALLOWED WITH NEW ONE
3703:         PUBBIT!OLDBIT
3704:         PUBBIT!PRIBIT
3705: IFN .-ASATBB-NASATT,<PRINTS /ASATBB WRONG SIZE
3706: />
3707: 
3708: ASSPPX: MOVE    AC2,TAC1                ;SAVE DEVICE NAME
3709:         PUSHJ   P,CTEXT1                ;GET LOGICAL NAME, IF ANY
3710:         MOVEM TAC1,ASSLGN               ;SAVE FOR LATER
3711:         MOVE TAC1,AC2                   ;RESTORE TAC1 TO PHYS NAME
3712:         HRRZS   (P)                     ;CLEAR PARTIAL MATCH FOUND FLAG
3713:         PUSH    P,DDB                   ;SAVE TTY DDB ADDRESS
3714:         MOVE    TAC,TAC1
3715:         PUSH P,AC1                      ;SAVE ATTRIBUTE BITS
3716:         PUSHJ   P,DEVPHY
3717:         JRST    ASSG3
3718:         POP P,AC1
3719:         MOVEI   TAC1,ASSCON
3720:         JRST    ASSG4
3721: 
3722: ASSG3:  POP P,AC1
3723:         MOVEI TAC1,ASSCON               ;SETUP ASSIGNED BY CONSOLE BIT
3724:         HLRZ DDB,DEVLST
3725: ASSG0:  MOVE TAC,DEVNAM(DDB)
3726:         CAME AC2,DEVNAM(DDB)            ;DOES PHYSICAL NAME MATCH?
3727:         JRST ASSG1                      ;NO
3728: ASSG4:  CAMN AC2,[SIXBIT /DSK/]         ;IS THIS A DISK?
3729:         JRST ASSG5                      ;YES.  BYPASS CHECK FOR SYSTEM TAPE
3730:         CAMN TAC,SYSTAP                 ;IS NEXT DEVICE IN LIST THE SYSTEM TAPE?
3731:         JRST ASSFIN                     ;YES, DO NOT ASSIGN. CLEAR DIRECTORY IN CORE BIT
3732: ASSG5:  PUSHJ P,ASSUDP                  ;TEST VARIOUS UDP CASES
3733:         JRST ASSR1A                     ;CAN'T GET UDPN SINCE PRIVATE AND NOT OURS
3734:         PUSHJ P,ASSCKS                  ;NOW CHECK FOR RECYCLABLE DDB
3735:         JRST ASLNOK                     ;I.E., SHARABLE DEVICE AND OUR ASSCON DDB
3736:         PUSHJ P,ASSASG                  ;TRY TO ASSIGN DEVICE
3737:         JRST ASSER1                     ;ALREADY ASSIGNED TO ANOTHER JOB
3738:         JRST ASSFIN                     ;ASSIGNED
3739: 
3740: ASSUDP: HLRZ AC3,TAC
3741:         CAIE AC3,'UDP'
3742:         JRST CPOPJ1                     ;NOT UDP.
3743:         LDB AC3,PUNIT
3744:         CAME AC2,[SIXBIT /UDP/]
3745:         JRST ASSUD1                     ;ASKED FOR UDPN.  SEE IF PUBLIC OR OURS
3746:         SKIPE UDPCNT-1(AC3)             ;ANY DDBS IN USE FOR THIS UDP?
3747:         POPJ P,                         ;YES.
3748: ASSUD2: TRNE AC1,PUBBIT                 ;WANTS TO MAKE IT PUBLIC?
3749:         JRST AUDPPB                     ;YES.
3750:         TRNE AC1,OLDBIT                 ;WANTS TO MAKE IT OLD STYLE?
3751:         JRST AUDPOL                     ;YES.
3752:         TRNN AC1,PRIBIT                 ;MAKE IT PRIVATE?
3753:         JRST CPOPJ1                     ;NO.
3754:         PUSHJ P,AUDPNU                  ;YES, FIRST MAKE IT NEW STYLE
3755:         PUSHJ P,AUDPPV                  ;THEN MAKE IT PRIVATE
3756:         JFCL                            ;IGNORE FAILURE RETURN
3757:         JRST CPOPJ1
3758: 
3759: AUDPPV: SKIPN UDPCNT-1(AC3)
3760:         JRST ASSUD3                     ;OK TO PRIVATIFY UNUSED UDP
3761:         PUSH P,DDB
3762: ASSUD4: HLRZ DDB,DEVSER(DDB)
3763:         JUMPE DDB,ASSUD5
3764:         CAME AC2,DEVNAM(DDB)
3765:         JRST ASSUD5                     ;NO MORE DDBS FOR THIS UDP
3766:         LDB TAC,PJOBN
3767:         CAIN TAC,(J)
3768:         JRST ASSUD4                     ;SAME JOB SAME UDP IS OK
3769:         MOVE DDB,-3(P)                  ;TTY DDB
3770:         PUSHJ P,INLMES
3771:         ASCIZ /ALREADY IN USE, CAN'T MAKE PRIVATE.
3772: /
3773:         POP P,DDB
3774:         MOVE TAC,DEVNAM(DDB)
3775:         POPJ P,                         ;FAILURE RETURN
3776: 
3777: ASSUD5: POP P,DDB
3778: ASSUD3: MOVE TAC,DEVNAM(DDB)
3779:         MOVEM J,UDPOWN-1(AC3)           ;MAKE UDP PRIVATE
3780:         JRST CPOPJ1                     ;SUCCESS RETURN
3781: 
3782: ASSUD1: SKIPL UDPOWN-1(AC3)             ;WANTS UDPN
3783:         CAMN J,UDPOWN-1(AC3)
3784:         JRST ASSUD2                     ;OK SINCE PUBLIC OR OURS
3785:         POPJ P,                         ;CAN'T GET UDPN SINCE PRIVATE NOT OURS
3786: 
3787: AUDPPB: PUSHJ P,AUDPNU                  ;WANTS PUBLIC: FIRST MAKE NEW-STYLE
3788:         LDB AC3,PUNIT
3789:         MOVE TAC,DEVMOD(DDB)            ;DDB POINTS TO MODEL DDB IT SAYS HERE
3790:         TLNE TAC,DVDSK                  ;IF WE MANAGED NEW-STYLE,
3791:         SETOM UDPOWN-1(AC3)             ;PUBLICIFY IT
3792:         JRST CPOPJ1
3793: 
3794: AUDPNU: LDB AC3,PUNIT                   ;TRY TO MAKE IT NEW-STYLE UDP
3795:         MOVE TAC,DEVMOD(DDB)
3796:         TLON TAC,DVDSK                  ;OK IF ALREADY NEW-STYLE
3797:         SKIPN UDPCNT-1(AC3)             ;OR IF NO DDBS YET
3798:         JRST AUDNOK
3799:         EXCH DDB,-2(P)                  ;TTY DDB
3800:         PUSHJ P,INLMES
3801:         ASCIZ /ALREADY IN USE, CAN'T CHANGE FORMAT.
3802: /
3803:         EXCH DDB,-2(P)
3804:         MOVE TAC,DEVNAM(DDB)
3805:         POPJ P,
3806: 
3807: AUDNOK: MOVEM TAC,DEVMOD(DDB)           ;SET FORMAT BIT
3808:         MOVEI TAC,DSKDSP
3809:         HRRM TAC,DEVSER(DDB)            ;SIGH, SET THE NEW DISPATCH TABLE TOO
3810:         MOVE TAC,DEVNAM(DDB)
3811:         POPJ P,
3812: 
3813: AUDPOL: PUSHJ P,AUDPPV                  ;WANTS OLD-STYLE.  FIRST PRIVATIFY
3814:         JRST CPOPJ1                     ;FAILED TO PRIVATIFY, SO NO OLD-STYLE
3815:         AOS (P)                         ;WIN OR LOSE, WE'VE ESTABLISHED ACCESS
3816:         LDB AC3,PUNIT                   ;TRY TO MAKE IT OLD-STYLE UDP
3817:         MOVE TAC,DEVMOD(DDB)
3818:         TLZE TAC,DVDSK                  ;OK IF ALREADY OLD-STYLE
3819:         SKIPN UDPCNT-1(AC3)             ;OR IF NO DDBS YET
3820:         JRST AUDOOK
3821:         EXCH DDB,-2(P)                  ;TTY DDB
3822:         PUSHJ P,INLMES
3823:         ASCIZ /ALREADY IN USE, CAN'T CHANGE FORMAT.
3824: /
3825:         EXCH DDB,-2(P)
3826:         MOVE TAC,DEVNAM(DDB)
3827:         POPJ P,
3828: 
3829: AUDOOK: MOVEM TAC,DEVMOD(DDB)           ;SET FORMAT BIT
3830:         MOVEI TAC,UDPDSP
3831:         HRRM TAC,DEVSER(DDB)            ;SIGH, SET THE OLD DISPATCH TABLE TOO
3832:         MOVE TAC,DEVNAM(DDB)
3833:         POPJ P,
3834: 
3835: ;ROUTINE TO TRY TO RECYCLE ASSCON-TYPE DDB FOR SHAREABLE DEVICE
3836: ASSCKS: MOVE AC3,DEVCMR(DDB)            ;FIRST OF ALL, GOTTA BE SHARABLE DEV
3837:         TLNN AC3,DEVSHR                 ;OR ASSASG WON'T COPY IT ANYWAY
3838:         JRST CPOPJ1
3839:         MOVE AC3,DDB                    ;NOW SEARCH ALL DDBS FOR THIS DEV
3840: ASCKS1: LDB TAC,[POINT 6,DEVCHR(AC3),5] ;PJOBN
3841:         CAIE TAC,(J)                    ;MUST MATCH OUR JOB TO BE A CANDIDATE
3842:         JRST ASCKS9                     ;ELSE CONTINUE THROUGH DDBS
3843:         MOVE TAC,DEVMOD(AC3)            ;MUST HAVE ASSCON
3844:         TRNN TAC,ASSCON                 ;PERHAPS NEEDLESSLY CONSERVATIVE, BUT
3845:         JRST ASCKS9                     ;PERHAPS SOMEONE NEEDS NOT CON+PRG SAME DDB
3846:         SKIPE TAC,DEVLOG(AC3)           ;OK IF NO LOGICAL NAME IN THE DDB
3847:         CAMN TAC,ASSLGN                 ;OR IF IT'S THE SAME AS LOG NAME ARG NOW
3848:         JRST ASCKS2
3849:         SKIPE ASSLGN                    ;ALSO OK IF NO LOG NAME ARG IN COMMAND
3850:         JRST ASCKS9                     ;BUT LOSE IF 2 DIFFERENT LOG NAMES
3851: ASCKS2: MOVE DDB,AC3                    ;GOT ONE!  SAVE POINTER
3852:         POPJ P,
3853: 
3854: ASCKS9: HLRZ AC3,DEVSER(AC3)            ;CONTINUE THROUGH DDB CHAIN
3855:         JUMPE AC3,CPOPJ1                ;CAN'T HAPPEN MAYBE
3856:         MOVE TAC,DEVNAM(AC3)            ;MAKE SURE THIS IS SAME DEVICE
3857:         CAMN TAC,DEVNAM(DDB)
3858:         JRST ASCKS1                     ;OK, CONTINUE TESTING
3859:         JRST CPOPJ1                     ;NO, POP AC3, SKIP RET
3860: 
3861: ;SYSTEM TAPE OR NOT MATCH OF ARG AND PHYSICAL NAME.
3862: 
3863: ASSG1:  CAMN    TAC,SYSTAP              ;IS THIS SYSTEM TAPE?
3864:         JRST    ASSG2                   ;YES
3865:         LDB     AC3,PJOBN               ;SAVE OLD JOB NUMBER FOR THIS DEVICE
3866:         MOVEM   AC3,ASSJBN
3867:         TRZ     TAC,-1                  ;COMPARE LEFT HALF ONLY
3868:         CAME    TAC,AC2
3869:         JRST    ASSG2
3870:         HRROS   -1(P)                   ;FLAG PARTIAL NAME MATCH FOUND
3871:         PUSHJ P,ASSUDP                  ;DO UDP CHECKS
3872:         JRST ASSG2                      ;THIS UDP NOT FREE TRY NEXT
3873:         PUSHJ P,ASSCKS                  ;NOW CHECK FOR RECYCLABLE DDB
3874:         JRST ASLNOK                     ;NONSKIP RETURN MEANS SUCCESS, GOT A DDB
3875:         PUSHJ   P,ASSASG                ;MATCH, TRY TO ASSIGN IT
3876:         JRST    ASSG2                   ;KEEP LOOKING
3877:         SKIPN ASSJBN
3878:         JRST ASSFIN             ;IF OLD JOB NUMBER 0,
3879:                                         ; DEVICE PREVIOUSLY UNASSIGNED
3880: 
3881: ASSG2:  HLRZ    DDB,DEVSER(DDB)
3882:         JUMPN   DDB,ASSG0
3883:         POP     P,DDB
3884:         SKIPL   (P)                     ;DID WE HAVE ANY PARTIAL MATCHES?
3885:         JRST    NOTDEV                  ;PRINT NO SUCH DEVICE
3886:         MOVE    DDB,-2(P)               ;RESTORE TTY DDB
3887:         PUSHJ   P,INLMES
3888:         ASCIZ   /SORRY, NO /
3889:         MOVE    TAC1,AC2
3890:         PUSHJ   P,PRNAME
3891:         JSP     TAC,CONMES              ;PRINT 'NO SUCH DEVICE'
3892:         ASCIZ   /'S AVAILABLE.
3893: /
    CLKSER page# 0070 next  prev
3895: ;ALREADY ASSIGNED TO ANOTHER JOB
3896: 
3897: ASSR1A: LDB TAC,PUNIT
3898:         SKIPA TAC,UDPOWN-1(TAC)         ;GET JOB NUMBER OF PRIVATE OWNER OF UDPN
3899: ASSER1: LDB     TAC,PJOBN               ;GET JOB NUMBER FOR DEVICE
3900:         POP     P,DDB                   ;GET DDB FOR TTY
3901:         PUSH    P,TAC                   ;SAVE JOB NUMBER
3902:         MOVEI   TAC,ASSMS2              ;TYPE ERROR MESSAGE
3903:         PUSHJ   P,ERRMES
3904:         POP     P,TAC                   ;GET JOB NUMBER BACK
3905:         JRST    DECLF
3906: 
3907: ASSMS2: ASCIZ /ALREADY ASSIGNED TO JOB /
3908: 
3909: ;DEVICE ASSIGNED, GIVE IT A LOGICAL NAME
3910: 
3911: ASSFIN: SETZM   DEVLOG(DDB)             ;CLEAR LOGICAL NAME
3912: ASLNOK: EXCH    DDB,(P)                 ;GET TTY DDB, SAVE DEVICE DDB
3913:         MOVE    TAC1,ASSLGN             ;RETRIEVE SAVED LOGICAL NAME ARG
3914:         SKIPN   TAC,TAC1                ;IS THERE A LOGICAL NAME SPECIFIED?
3915:         JRST    DEFASS                  ;NO.  CHECK FOR DEFAULTING ASSIGNMENT
3916:         PUSHJ   P,DEVLG                 ;SEE IF IT IS ALREADY IN USE BY THIS USER
3917:         JRST    ASSF1                   ;NO
3918:         MOVEI   TAC,LOGERR              ;YES, PRINT ERROR
3919:         MOVE    DDB,-3(P)               ;RESTORE TTY DDB
3920:         PUSHJ   P,ERRMES
3921: DEFLOS: MOVEI   TAC,0                   ;CLEAR LOGICAL NAME FOR THIS DEVICE
3922: ASSF1:  POP     P,DDB
3923:         SKIPN DEVLOG(DDB)               ;WILL BE NONZERO ONLY FOR RECYCLED DDB
3924:         MOVEM   TAC,DEVLOG(DDB)         ;STORE IN DEVICE DATA BLOCK
3925:         MOVSI   TAC1,DVDIRIN            ;CLEAR DIRECTORY IN CORE BIT
3926:         ANDCAM  TAC1,DEVMOD(DDB)
3927:         MOVE    TAC1,DEVNAM(DDB)        ;PHYSICAL NAME
3928:         MOVE    AC2,DDB
3929:         MOVE    DDB,-2(P)               ;RESTORE TTY DDB
3930:         PUSHJ   P,PRNAME                ;PRINT IT
3931:         PUSHJ   P,INLMES
3932:         ASCIZ   / ASSIGNED/
3933:         SKIPN   DEVLOG(AC2)
3934:         JRST    NOLOGP
3935:         PUSHJ   P,INLMES
3936:         ASCIZ   / AS /
3937:         MOVE    TAC1,DEVLOG(AC2)
3938:         PUSHJ   P,PRNAME
3939: NOLOGP: JSP     TAC,CONMES
3940:         ASCIZ/
3941: /
3942: 
3943: LOGERR: ASCIZ   /LOGICAL NAME ALREADY IN USE, /
3944: 
3945: DEFASS: MOVE    DDB,(P)
3946:         CAME    AC2,DEVNAM(DDB)
3947:         CAMN    AC2,['TTY   ']          ;DON'T DO IT FOR TTY
3948:         JRST    ASSF1
3949:         MOVE    TAC,AC2
3950:         PUSHJ   P,DEVLG                 ;INUSE?
3951:         JRST    ASSF1
3952:         JRST    DEFLOS
    CLKSER page# 0071 next  prev
3954: ;"DEASSIGN DEV" - DEASSIGNS DEVICE FROM CONSOLE
3955: 
3956: 
3957: DEASSI: JUMPE ITEM,CPOPJ        ;NO-OP IF NO JOB NUMBER
3958:         PUSHJ PDP,CTEXT1        ;GET DEVICE NAME
3959:         JUMPE TAC1,DEALL        ;NO ARG. IF 0, DEASSIGN ALL BUT TTY
3960:         MOVE TAC, TAC1          ;DEVICE NAME
3961: DEAER4: PUSHJ PDP,DEVLG         ; SEARCH LOGICAL NAMES FIRST
3962:         JRST DEAER3
3963:         PUSHJ PDP,DEASG
3964:         CAIA
3965:         JRST DEADON
3966:         PUSH PDP,[DEAER4+1]
3967:         JRST DEV0
3968: DEAER3: PUSHJ PDP,DEVPHY        ; NOT FOUND, TRY PHYSICAL NAMES
3969:         JRST DEAER2             ; NOT FOUND AT ALL, LOSE!
3970:         PUSHJ PDP,DEASG         ; FOUND, DEASSIGN IT
3971:         CAIA
3972:         JRST DEADON
3973:         MOVE AC1,DEVMOD(DDB)
3974:         TLNE AC1,DVTTY          ; STOP IF FOUND A TTY
3975:         POPJ P,                 ; QUIT HERE OR WILL LOOP INDEFINITELY!!!!
3976:                                 ; ALSO FLUSH UNUSED TTY'S
3977:         PUSH PDP,[DEAER3+1]
3978:         JRST DEVLP2
3979: 
3980: DEADON: MOVE AC1,DEVMOD(DDB)
3981:         TLNE AC1,TTYATC         ; NOT FOR CONSOLE OF LOSER
3982:         POPJ P,
3983:         TRNN AC1,ASSPRG         ; STILL ASSIGNED BY PROGRAM?
3984:         JRST DEADN1
3985:         MOVE TAC1,DEVNAM(DDB)
3986:         MOVE DDB,-2(P)
3987:         PUSHJ P,PRNAME
3988:         JSP TAC,ERRMES
3989:         ASCIZ/ DEASSIGNED, BUT STILL INITED!
3990: /
3991: 
3992: DEADN1: TLNN AC1,DVTTY          ; IF TTY
3993:         POPJ P,
3994:         JRST TTYREL             ; RELEASE IT SO DDB WILL BE LET GO
3995: 
3996: NOTDEV:
3997: DEAER1: MOVE DEVDAT,-2(PDP)     ; RESTORE TTY DDB
3998:         JSP TAC,ERRMES          ; PRINT 'NO SUCH DEVICE'
3999: 
4000:         ASCIZ /NO SUCH DEVICE
4001: /
4002: 
4003: DEAER2: MOVE TAC1,TAC                   ;PRINT PHYSICAL DEVICE NAME
4004:         MOVE DEVDAT,-2(PDP)             ; RESTORE TTY DDB FIRST
4005:         PUSHJ PDP,PRNAME
4006:         JSP TAC,ERRMES
4007: 
4008:         ASCIZ / WASN'T ASSIGNED
4009: /
4010: 
4011: DEALL:  PUSH P,DDB
4012:         SETZ DDB,
4013:         PUSHJ P,DEASTY
4014:         POP P,DDB
4015:         POPJ P,
    CLKSER page# 0072 next  prev
4017: ;REASSIGN UUO
4018: ;CALL   MOVE AC,JOB NUMBER
4019: ;       MOVE AC+1,SIXBIT /DEVICE/
4020: ;       CALL AC,[SIXBIT /REASSIGN/]
4021: ;IF C(AC)=0, JOB HAS NOT BEEN INITIALIZED
4022: ;IF C(AC+1)=0, DEVICE NOT ASSIGNED TO THIS JOB OR DEVICE IS A TTY
4023: 
4024: 
4025: 
4026: REASSI:
4027:         LDB UUO,PUUOAC
4028:         HRLI UUO,PROG
4029:         PUSH PDP,@UUO           ;STACK JOB NUMBER TO BE REASSIGNED TO
4030:         AOS UUO
4031:         MOVE TAC1,@UUO          ;DEVICE NAME
4032:         MOVE ITEM,JOB(PID)      ;THIS JOB NUMBER
4033:         SOJA UUO,REASS1
4034: 
4035: ;"REASSIGN DEV:JOB" - REASSIGN DEVICE "DEV" TO JOB "JOB"
4036: 
4037: 
4038: REASS:
4039:         PUSHJ PDP,CTEXT1        ;GET DEVICE NAME
4040:         JUMPE TAC1,NOTENF       ;NULL NAME?
4041:         MOVE UUO,TAC1           ;SAVE IT IN UUO
4042:         PUSHJ PDP,DECIN1        ;GET NEW JOB NUMBER
4043:         JRST NOTENF             ;NONE SPECIFIED. DOESN'T RETURN IF ERROR
4044:         JRST COMERA             ;ILLEGAL CHARACTER
4045:         PUSH PDP,TAC1           ;PUT JOB NUMBER ON STACK, DEVICE
4046:         MOVE TAC1,UUO           ;NAME IN TAC1
4047:         SETZM UUO               ;SET COMMAND SWITCH
4048: 
    CLKSER page# 0073 next  prev
4050: ;ROUTINE COMMON TO REASSIGN UUO AND COMMAND
4051: 
4052: 
4053: REASS1: EXCH ITEM,(PDP)         ;NEW JOB NO. IN ITEM
4054:         MOVE TAC,JBTSTS(ITEM)   ;NEW JOB STATUS
4055:         EXCH ITEM,(PDP)         ;RESTORE ITEM AND STACK
4056:         TLNN TAC,JNA            ;DOES NEW JOB EXIST?
4057:         JRST REASE1             ;NO.
4058:         MOVE TAC,TAC1
4059:         PUSHJ PDP,FNDDDB        ;SEARCH FOR DEV (USE CHANNEL # IF UUO)
4060:         JRST REASE2             ;NOT FOUND
4061:         LDB TAC,PJOBN
4062:         CAME TAC,ITEM           ;ASSIGNED TO THIS JOB
4063:         JRST REASE3             ;NO
4064:         MOVE TAC,DEVMOD(DEVDAT)
4065:         TLNE TAC,TTYATC         ;IS IT HIS CONSOLE?
4066:         JRST REASE6             ;YES. CAN'T BE REASSIGNED.
4067:         TRNN TAC,ASSPRG         ;IS DEVICE INITED?
4068:         JRST REASS3             ;NO.
4069:         JUMPN UUO,REASS4        ;YES. COMMAND LEVEL?
4070:         HRL DEVDAT,(PDP)        ;YES. SCHEDULE RELEASE
4071:         MOVEM DEVDAT,JOBFDV(JDAT)
4072:         POP PDP,TAC1
4073:         MOVE DEVDAT,-2(PDP)
4074:         MOVSI TAC1,TTYRNC       ;SET TTYRNC SO JOB WILL RUN
4075:         IORM TAC1,-1(PDP)
4076:         JSP TAC1,MSTART
4077:         JSP TAC,MONSTR
4078:         HLRZ TAC,JOBFDV(JDAT)
4079:         PUSH PDP,TAC
4080:         HRRZ DEVDAT,JOBFDV(JDAT)
4081:         MOVE ITEM,JOB(PID)
4082:         SETOM UUO               ;SET FLAG TO STOP JOB
    CLKSER page# 0074 next  prev
4084: REASS4: HRRZ DSER,DEVSER(DEVDAT)
4085:         HRRZM DEVDAT,JOBFDV(JDAT)
4086:         SKIPGE UCHN,USRHCU(PID) ; HAS MONDMP BEEN HERE?
4087:         JRST REASS3             ;YES, WE CAN'T BE IN USRJDA LIST
4088: REASS2: HRRZ DEVDAT,USRJDA(UCHN)
4089:         PUSH PDP,UCHN
4090:         CAME DEVDAT,JOBFDV(JDAT)
4091:         JRST REASS8
4092:         HLL DEVDAT,USRJDA(UCHN) ; PICK UP UUO FLAGS FIRST
4093:         PUSHJ PDP,RELEA5        ; NOW RELEASE DEVICE
4094: REASS8: POP PDP,UCHN
4095:         SOJGE UCHN,REASS2
4096:         SKIPL UCHN,JBTIOP(J)
4097:         JRST REAST1
4098: REAST2: HRRZ DDB,(UCHN)
4099:         CAME DDB,JOBFDV(JDAT)
4100:         JRST REAST3
4101:         MOVE DDB,USRJDA
4102:         EXCH DDB,(UCHN)
4103:         MOVEM DDB,USRJDA
4104:         PUSH P,UCHN
4105:         SETZ UCHN,
4106:         PUSHJ P,RELEA5
4107:         POP P,UCHN
4108:         MOVE DDB,(UCHN)
4109:         EXCH DDB,USRJDA
4110:         MOVEM DDB,(UCHN)
4111: REAST3: ADD UCHN,[1,,1]
4112:         AOBJN UCHN,REAST2
4113: REAST1: MOVE DEVDAT,JOBFDV(JDAT)
4114: REASS3: MOVEI TAC,ASSCON        ;ASSIGN IT BY CONSOLE
4115:         IORM TAC,DEVMOD(DEVDAT)
4116:         POP P,J
4117:         DPB J,PJOBN             ;PUT IN NEW JOB NUMBER
4118:         SETZM DEVLOG(DDB)       ;FLUSH LOGICAL DEVICE NAME!
4119:         MOVE J,JOB(PID)
4120:         JUMPL UUO,ESTOP
4121:         POPJ PDP,
    CLKSER page# 0075 next  prev
4123: REASE1: POP PDP,TAC
4124:         JUMPE UUO,NOTLOG        ;PRINT NO SUCH JOB
4125: REASE4: SETZM @UUO              ;CLEAR C(AC)
4126:         POPJ PDP,
4127: 
4128: REASE2: MOVEI TAC,NOTDEV        ;NO SUCH DEVICE
4129: REASE5: POP PDP,TAC1
4130:         JUMPE UUO,(TAC)
4131:         AOJA UUO,REASE4
4132: 
4133: REASE3: MOVEI TAC,REASSX        ;WASN'T ASSIGNED
4134:         JRST REASE5
4135: 
4136: REASE6: MOVEI TAC,REASE7
4137:         JRST REASE5
4138: REASE7: MOVE TAC1,DEVNAM(DEVDAT)
4139:         MOVE DEVDAT,-2(PDP)     ; RESTORE TTY DDB
4140:         PUSHJ PDP,PRNAME
4141:         JSP TAC,ERRMES
4142:         ASCIZ / CAN'T BE REASSIGNED
4143: /
4144: 
4145: REASSX: MOVE TAC1,DEVNAM(DEVDAT)
4146:         JRST DEAER2+1
    CLKSER page# 0076 next  prev
4148: ;"ATTACH DEVNAM" -ATTACHES A PREVIOUSLY PARTITIONED DEVICE
4149: ;       NOTE-MUST BE LOGGED IN UNDER [1,1] TO DO THIS
4150: ; "ATTACH N [PROJ.,PROG.]" - ATTACH CONSOLE TO JOB N
4151: ;CHANGES ADDRESS OF TTY DEVICE DATA BLOCK STORED IN -2(PDP)
4152: ;BY THE COMMAND DECODER
4153: 
4154: 
4155: 
4156: ATTACH:
4157:         PUSHJ   P,DECIN         ;GET JOB NO.
4158:         JRST    NOTENF          ;NOT A NUMBER OR NONE SPECIFIEED
4159: IFN FTLOGIN,<
4160:         JRST    DEVATT          ;WANTS TO ATTACH A DEVICE
4161: >
4162: IFE FTLOGIN,<
4163:         JRST    NOTLOG          ;NO SUCH JOB
4164: >
4165:         JUMPE   TAC1,NOTLOG     ;0 IS ILLEGAL
4166:         CAIL    TAC1,JOBN       ;IS JOB NUMBER TOO BIG?
4167:         JRST    NOTLOG          ;ILLEGAL JOB NUMBER.  PRINT NO SUCH JOB
4168:         MOVSI   AC2,JNA         ;HAS THIS JOB NO BEEN ASSIGNED?
4169:         TDNN    AC2,JBTSTS(TAC1)
4170:         JRST    NOTLOG          ;NO, PRINT NO SUCH JOB
4171: IFN FTLOGIN,<
4172:         PUSH    P,TAC1          ;SAVE JOB NO.
4173:         PUSHJ   P,PJPGNO        ;GET PROJ.-PROG. NOS. ARG
4174:         MOVE    AC2,PRJPRG(J)   ;NO PP NO. USE CURRENT ONE
4175:         POP     P,TAC1          ;RESTORE
4176:         CAME    AC2,PRJPRG(TAC1);MATCHES THE DETACHED JOB'S PPN?
4177:         JRST    ATT3            ;NO-ERROR
4178:                                 ;YES
4179: >
4180:         LDB     TAC,PUNIT       ;GET LINE NUMBER OF TTY THAT'S TYPING.
4181:         JRST    .+2
4182: ATTILA: HRRE    TAC,JBTLIN(J)   ;GET LINE NUMBER OF CONTROLING JOB.
4183:         CAIGE   TAC,PTYL0       ;IS THIS ON A PTY?
4184:         JRST    THEHUN          ;NO. ATTACH IS LEGAL.
4185:         MOVE    J,PTYJOB-PTYL0(TAC)     ;GET JOB NUMBER OF CONTROLING JOB.
4186:         CAIE    J,(TAC1)        ;CONTROLLER=JOB TO ATTACH TO?
4187:         JRST    ATTILA          ;NO.  KEEP LOOPING
4188:         MOVEI   J,0
4189:         JSP     TAC,ERRMES
4190:         ASCIZ   /ILLEGAL ATTACH LOOP
4191: /
4192: 
4193: THEHUN: MOVE    J,TAC1          ;JOB NUMBER TO J
4194:         PUSHJ   P,COMRT2        ;FIX COMCNT
4195:         PUSHJ   P,TTYATT        ;NO, ATTACH TTY
4196:         JRST    ATT2            ;ERROR CAN'T ATTACH
4197:         MOVEM   DDB,-2(P)       ;CHANGE DEV DATA BLOCK ADDRESS
4198:         JRST    TTYFND          ;ATTACHED. GO SET UP OUTPUT BYTE PTR.
    CLKSER page# 0077 next  prev
4200: IFN FTLOGIN,<
4201: DEVATT:
4202:         ADDI    TEM,20          ; MAKE FIRST CHAR OF DEVICE NAME INTO SIXBIT
4203:         PUSH    P,TEM           ; NOW SAVE IT
4204:         PUSHJ   P,CTEXT         ;GET DEVICE ARGUMENT
4205:         JFCL                    ;SHOULD NEVER RETURN
4206:         POP     P,TEM           ; GET CHARACTER BACK
4207:         MOVE    AC1,JBTPRV(J)   ;GET JOB PRIVILEGES.
4208:         TLNN    AC1,DEVPRV      ;HAS HE THIS PRIV?
4209:         JRST    ATT5            ;NO - ERROR
4210:         MOVE    TAC,TAC1        ;YES-SET UP DEVICE NAME
4211:         LSH     TAC,-6
4212:         DPB     TEM,[POINT 6,TAC,5]
4213:         PUSH    P,DDB           ;SAVE DDB FOR THIS TTY
4214:         PUSHJ   P,DEVSRC        ;SEARCH FOR DEVICE
4215:         JRST    DADD01          ;NOT FOUND
4216:         LDB     AC1,PJOBN       ;GET JOB NUMBER
4217:         JUMPN   AC1,ATT6        ;IS IT = 0?
4218:         MOVE    TAC,DEVMOD(DDB) ;CHECK TO SEE IF THIS IS A TTY
4219:         TLNE    TAC,DVUDP
4220:         JRST    ATTUDP          ;UDP IS SPECIAL
4221:         TRNE    TAC,ASSPRG      ;IN USE BY JOB 0?
4222:         JRST    ATT5A           ;YES, CAN'T ATTACH IT
4223:         DPB     J,PJOBN         ;SET JOB NUMBER
4224:         LDB     TAC1,PUNIT      ;
4225:         TLNE    TAC,DVTTY       ;IS IT A TTY?
4226:         HRRM    DDB,TTYTAB(TAC1);DEC 3.16
4227: DADD02: POP     P,DDB           ;
4228:         POPJ    P,              ;RETURN
4229: 
4230: ATTUDP: LDB TAC,PUNIT           ;TRYING TO ATTACH UDP
4231:         SKIPN UDPCNT-1(TAC)     ;MUST BE NO DDBS
4232:         SKIPE UDPOWN-1(TAC)     ;AND OWNER 0
4233:         JRST ATT6               ;ELSE IN USE, PUBLIC, OR SWAPPING DEVICE!
4234:         SETOM UDPOWN-1(TAC)     ;OK, MAKE IT PUBLIC
4235:         JRST DADD02             ;NOTE THAT YOU DON'T HAVE IT ASSIGNED NOW!
4236: 
4237: ;NOTE: THIS ROUTINE IS ALSO CALLED FROM PJOB COMMAND
4238: DADD00: MOVEI TAC1,0            ;SUBROUTINE TO CHECK "DEV" NAME FOR DD
4239:         ROTC TAC,14
4240:         CAIN TAC1,'DD'          ;NOT A DEVICE, IS IT A DD CHANNEL?
4241:         PUSHJ P,SIX2LN          ;YES, GOBBLE NUMBER
4242:         POPJ P,                 ;NOT DD OR NO NUMBER
4243:         CAIL TAC1,=32
4244:         POPJ P,
4245:         MOVSI TAC,DDDETU!DDANYW ;DETACHED USE CODE
4246:         HRRI TAC,(TAC1)
4247:         JRST CPOPJ1
4248: 
4249: DADD01: PUSHJ P,DADD00          ;NOT A REAL DEVICE, TRY DD CHAN
4250:         JRST TEMP1              ;NOPE
4251:         LDB TAC1,[DDUSR+<(TAC)>];YES, LOOK AT ITS USE CODE
4252:         CAIE TAC1,DDDETU
4253:         JRST ATT6               ;WASN'T DET
4254:         PUSHJ P,DDREL           ;LET GO!!
4255:         JRST DADD02
4256: >
    CLKSER page# 0078 next  prev
4258: ATT2:   EXCH    DDB,TAC1                ;PUT LINE NO. OF OUR TTY IN DDB
4259:         MOVE    TAC1,DEVNAM(TAC1)       ;PRINT PHYSICAL NAME
4260:         MOVE    DDB,TTYTAB(DDB)         ;PRINT MESSAGE ON RIGHT TTY !!
4261:         PUSHJ   P,PRNAME
4262:         JSP     TAC,ERRMES
4263:         ASCIZ   / ALREADY ATTACHED
4264: /
4265: 
4266: ATT3:   JSP     TAC,ERRMES
4267:         ASCIZ   /PROJECT-PROGRAMMER NUMBER MISMATCH
4268: /
4269: 
4270: ATT5A:  POP     P,DDB
4271: ATT5:   JSP     TAC,ERRMES
4272:         ASCIZ   /CAN'T ATT DEV
4273: /
4274: 
4275: ATT6:   POP     P,DEVDAT
4276:         JSP     TAC,ERRMES
4277:         ASCIZ   /WASN'T DET
4278: /
    CLKSER page# 0079 next  prev
4280: ;FLUSH THIS TTY'S BUFFERS IF NOT IN USE BY A JOB
4281: 
4282: FLUSH:  PUSHJ P,CTEXT1
4283:         JUMPE TAC1,NOTENF       ;NO ARG?
4284:         MOVE TAC,TAC1
4285:         PUSHJ P,LOG2LN          ;CONVERT TO LINE NUMBER
4286:         JRST NOTTTY
4287:         SKIPN DDB,TTYTAB(TAC1)
4288:         JRST FLUSH1
4289:         LDB TAC,PJOBN
4290:         CAME TAC,J              ;LET HIM DO IT TO HIMSELF
4291:         JUMPN TAC,INUSE         ;JOB ON IT
4292:         PUSHJ P,TSETBF          ;CLEAR BUFFERS
4293:         MOVSI TAC,TPMON!IOFST
4294:         MOVEM TAC,DEVIOS(DDB)   ;MAKE HIM A VIRGIN
4295: FLUSH1: MOVE DDB,-2(P)          ;GET BACK OUR DDB
4296:         MOVEI DAT,TTOBUF(DDB)
4297:         JSP TAC,CONMES
4298:         ASCIZ/FLUSHED./
4299: 
4300: NOTTTY: MOVE DDB,-2(P)
4301:         MOVEI DAT,TTOBUF(DDB)
4302:         JSP TAC,ERRMES
4303:         ASCIZ/NOT A TTY.
4304: /
4305: 
4306: INUSE:  MOVE DDB,-2(P)
4307:         MOVEI DAT,TTOBUF(DDB)
4308:         JSP TAC,ERRMES
4309:         ASCIZ/IN USE.
4310: /
    CLKSER page# 0080 next  prev
4312: ;"FORK", "CFORK", "DETACH" AND "CDETACH" COMMANDS
4313: ;"DETACH" - DETACH CONSOLE FROM JOB 
4314: ;"DETACH DEVNAM" - DETACHES DEVICE FROM THE SYSTEM SOFTWAREWISE
4315: 
4316: MFORK:  PUSH    P,J             ;SAVE J
4317:         PUSHJ   P,INIJOB        ;INITIALIZE A JOB
4318:         JRST    [POP    P,J     ;NO JOBS AVAILABLE.
4319:                 POP     P,(P)   ;FLUSH CALL TO MFORK
4320:                 MOVSI   TAC,NOMESS      ;LET ERROR MESSAGE THROUGH
4321:                 ANDCAM  TAC,-1(P)
4322:                 JRST    LOSEJB] ;
4323:         JRST    [POP    P,J
4324:                 POP     P,(P)
4325:                 JRST    DLYCM1] ;DELAY THIS COMMAND UNTIL FREE STORAGE AVAILABLE
4326:         MOVE    TAC,J
4327:         POP     P,J
4328:         POPJ    P,
4329: 
4330: CFORK:  MOVSI   TAC,JERR
4331:         TDNE    TAC,JBTSTS(J)
4332:         JRST    NOCONT
4333:         MOVM    TAC,JOBQUE(J)
4334:         CAIE    TAC,STOPQ       ;START HIM ONLY IF STOPPED.
4335:         JRST    FORK            ;ALREADY RUNNING(MIGHT NOT BE IN RUNQ)
4336:         PUSHJ   P,MFORK         ;GET A NEW JOB NUMBER IN TAC
4337:         PUSH    P,TAC
4338:         MOVNI   TAC,RUNQ
4339:         MOVEM   TAC,JOBQUE(J)
4340:         PUSHJ   P,REQUE
4341:         PUSHJ   P,SETRUN
4342:         JRST    FORK1           ;WE HAVE NEW JOB NUMBER ON STACK.
4343: 
4344: FORK:   PUSHJ   P,MFORK         ;GET US A NEW JOB NUMBER IN TAC
4345:         PUSH    P,TAC           ;ALL SET.
4346: FORK1:  PUSH    P,JBTLIN(J)
4347:         PUSHJ   P,DETCH1
4348:         POP     P,TAC1          ;GET BACK OLD LINE NUMBER
4349:         HRLM    J,-1(P)         ;SAVE THE OLD JOB NUMBER ON TOP OF PC FLAGS
4350:         PUSHJ   P,DDBSRC        ;GET A NEW DDB
4351:         JRST    [POP    P,J     ;LOSE.
4352:                 PUSHJ   P,RELJOB        ;RELEASE THE JOB WE GOT
4353:                 MOVEI   J,0     ;SIGNAL ERROR TO COMRET
4354:                 POPJ    P,]
4355:         MOVSI   TAC,NOMESS
4356:         ANDCAM  TAC,-2(P)       ;OK TO TALK NOW
4357:         MOVEM   DDB,-3(P)       ;AND WHERE TO SAY IT
4358:         MOVEI   DAT,TTOBUF(DDB)
4359:         POP     P,J             ;GET THE JOB NUMBER OF NEW JOB.
4360:         PUSHJ P,FORKC           ;COPY OLD JOB'S POOP
4361:         PUSHJ P,PRJOB
4362:         PUSHJ P,INLMES
4363:         ASCIZ/
4364: FORK YOU VERY MUCH!/
4365:         JRST PRCRCC
4366: 
4367: FORKC: MOVSI   TAC,JLOG!JNA
4368:         IORM    TAC,JBTSTS(J)   ;MAKE THIS JOB HIS
4369:         SETZM   DEVLOG(DDB)     ;ZERO LOGICAL NAME OF TTY
4370:         PUSHJ   P,TTYATI
4371:         HLRZ    TAC,-1(P)       ;GET THE OLD JOB NUMBER BACK
4372:         MOVE    TAC,PRJPRG(TAC)
4373:         MOVEM   TAC,PRJPRG(J)   ;GIVE HIM SAME PPN
4374:         HLRZ    TAC,-1(P)
4375:         MOVE    TAC,JBTPRV(TAC)
4376:         MOVEM   TAC,JBTPRV(J)   ;COPY PRIVILEGES
4377:         HLRZ TAC,-1(P)
4378:         MOVE TAC,JB2PRV(TAC)
4379:         MOVEM TAC,JB2PRV(J)     ;ALSO PASSIVE ONES
4380:         PUSHJ   P,SETLOG        ;GET GOOD STUFF
4381:         HLRZ    TAC,-1(P)       ;GET THE OLD JOB NUMBER BACK
4382:         MOVE    TAC,DSKPPN(TAC)
4383:         MOVEM   TAC,DSKPPN(J)   ;GIVE HIM THE SAME ALIAS
4384:         POPJ P,
4385: 
4386: LOSEJB: JSP     TAC,ERRMES
4387:         ASCIZ/JOB CAPACITY EXCEEDED!
4388: /
4389: 
4390: CDETACH:MOVSI   TAC,JERR
4391:         TDNE    TAC,JBTSTS(J)
4392:         JRST    NOCONT
4393:         MOVM    TAC,JOBQUE(J)
4394:         CAIE    TAC,STOPQ
4395:         JRST    DETCH1
4396:         MOVNI   TAC,RUNQ
4397:         MOVEM   TAC,JOBQUE(J)
4398:         PUSHJ   P,REQUE
4399:         PUSHJ   P,SETRUN
4400: IFE FTLOGIN,<DETACH:>
4401: DETCH1: PUSHJ   P,COMRT2        ;FIX COMMAND BIT, COMCNT BEFORE DETACHING.
4402:         JRST    TTYDET          ;GO DETACH TTY.
4403: 
4404: IFN FTLOGIN,<
4405: 
4406: DETACH: PUSHJ   P,CTEXT         ;GET ARGUMENT
4407:         JUMPE   TAC1,DETCH1     ;ONLY "DET" TYPED
4408:         MOVE    AC1,JBTPRV(J)   ;GET PRIV BITS
4409:         TLNN    AC1,DEVPRV      ;DEVICE DETACH-ATTACH PRIV?
4410:         JRST    LOGER1          ;NO-PRINT ERROR MSG.
4411:         MOVE    TAC,TAC1        ;YES-SET UP DEVICE NAME
4412:         PUSH    P,DDB           ;SAVE TTY DDB
4413:         PUSHJ   P,DEVSRC        ;SEARCH FOR DEVICE
4414:         JRST    DDDD01          ;DEVICE NOT FOUND
4415:         MOVE    TAC,DEVMOD(DDB) ;CHECK TO SEE IF THIS IS DSK
4416:         TLNE    TAC,DVUDP       ;IS IT A UDP?
4417:         JRST    DDDUDP          ;YES, BIG MESS
4418:         TLNE    TAC,DVDSK       ;IS IT THE DSK?
4419:         JRST    TEMP1           ;YES-PRINT ERROR MSG.
4420:         MOVEI   TAC1,ASSCON     ;FOUND-SET UP ASSIGNED BY CONSOLE
4421:         PUSHJ   P,ASSASG        ;TRY TO ASSIGN
4422:         JRST    ASSER1          ;CAN'T ASSIGN
4423:         TLNE    DDB,SYSDEV      ;IS THIS SYSTEM DEVICE?
4424:         JRST    TEMP1           ;YES-PRINT ERROR MSG.
4425:         XOR     AC1,AC1         ;NO-SET TO ZERO
4426:         DPB     AC1,PJOBN       ;SET JOB NO. TO NULL JOB
4427:         MOVE    TAC,DEVMOD(DDB) ;CHECK TO SEE IF THIS IS A TTY
4428:         TLNN    TAC,DVTTY       ;IS IT A TTY?
4429:         JRST    DDDD03          ;NO-GO AHEAD
4430:         LDB     TAC,PUNIT       ;YES-SET UP FOR SCNSER
4431:         MOVEI   TAC1,-1         ;SET LEFT HALVE OF TTYTAB TO -1
4432:         HRRM    TAC1,TTYTAB(TAC);SO THAT SCNSER CHECKS FOR THIS
4433: DDDD03: POP     P,DEVDAT        ;RESTORE OUR TTY DDB
4434:         MOVSI   TAC,NOPER!NOCRLF!NOMESS ; ASK TO TYPE OUT A CRLF AND A PERIOD
4435:         ANDCAM  TAC,-1(P)       ; BY ZEROING THESE IN THE COMMAND FLAGS
4436:         POPJ    P,              ;SUCCESSFUL RETURN
4437: 
4438: DDDUDP: LDB TAC,PUNIT           ;TRYING TO DETACH UDP, GET UNIT NUMBER
4439:         SKIPE UDPCNT-1(TAC)     ;MUST HAVE NO OUTSTANDING DDBS
4440:         JRST ASSER1             ;ELSE LOSE
4441:         SETZM UDPOWN-1(TAC)     ;OK, SET JOB 0 AS OWNER
4442:         JRST DDDD03             ;ANNOUNCE WIN
4443: 
4444: TEMP1:  POP     P,DDB           ;RESTORE TTY DDB
4445:         JRST    DEAER1          ;PRINT ERROR MSG. AND RETURN
4446: 
4447: LOGER1: JSP     TAC,ERRMES
4448:         ASCIZ   /CAN'T DET DEV
4449: /
4450: 
4451: DDDD01: PUSHJ P,DADD00          ;NOT A DEV, TRY DD CHAN
4452:         JRST TEMP1              ;N
4453:         PUSHJ P,DDCGET
4454:         JRST DDDD02             ;IN USE
4455:         JRST DDDD03             ;WIN
4456: DDDD02: POP P,DDB
4457:         JSP TAC,ERRMES
4458:         ASCIZ /CHANNEL IN USE
4459: /
4460: >       ;CLOSE FTLOGIN
    CLKSER page# 0081 next  prev
4462: ;"DAYTIME" - PRINT TIME OF DAY
4463: DAYTIM:
4464:         PUSHJ   P,DECIN         ;PICK UP JOB NUMBER ARGUMENT
4465:         JRST    DAYT2           ;NO ARGUMENT.  GIVE HIM DAY, DATE & TIME
4466:         JRST    COMERA          ;ILLEGAL DECIMAL ARGUMENT
4467:         JUMPN   TAC1,.+2        ;ZERO ARGUMENT?
4468:         MOVE    TAC1,J          ;YES.  "DAYTIME 0" GETS TIMES FOR OWN JOB
4469:         MOVE    TAC,JBTSTS(TAC1)
4470:         TLNE    TAC,JNA
4471:         TLNE    TAC,JSEG
4472:         JRST    NOTLOG          ;NO JOB OR A SEGMENT.  PRINT NO SUCH JOB.
4473: 
4474:         PUSH    P,[0]           ;INITIALIZE A FLAG: DONT PRINT DATES
4475:         HLRZ    TAC,JBTBTM(TAC1);GET LOGIN DATE
4476:         CAME    TAC,THSDAT      ;DID HE LOGIN TODAY?
4477:         SETOM   (P)             ;NO.  FLAG TO PRINT DATES
4478:         MOVEI   TAC,[ASCIZ /LOGIN   RUN    NOW
4479: /]
4480:         SKIPE   (P)             ;PRINTING DATES?
4481:         MOVEI   TAC,[ASCIZ /  LOGIN      RUN       NOW
4482: /]                              ;YES, LEAVE ROOM FOR DATES
4483:         PUSHJ   P,CONMES        ;PRINT TITLES
4484:         MOVE    TAC,JBTBTM(TAC1);GET LOGIN DATE/TIME
4485:         PUSHJ   P,PRDATM        ; AND PRINT IT
4486:         MOVE    TAC,FTIME(TAC1) ;GET DATE/TIME LAST RUN
4487:         PUSHJ   P,PRDATM        ; AND PRINT IT
4488:         MOVE    TAC,TIMDAT      ;GET CURRENT DATE/TIME
4489:         PUSHJ   P,PRDATM        ; AND PRINT IT
4490:         SUB     P,[1,,1]        ;POP FLAG
4491:         JRST    CRLF            ;PRINT CRLF, AND RETURN
4492: 
4493: PRDATM: SKIPN   -1(P)           ;ARE WE PRINTING DATES?
4494:         JRST    PDTIM0          ;NO.  JUST PRINT TIME
4495:         PUSH    P,TAC1          ;YES.
4496:         PUSH    P,TAC
4497:         HLRZ    TAC,TAC         ;GET DATE
4498:         IDIVI   TAC,=31         ;CONVERT TO DAY OF MONTH
4499:         MOVEI   TAC,1(TAC1)     ; WHICH IS THE REMAINDER+1
4500:         MOVEI   TEM," "
4501:         PUSHJ   P,PRTIM3        ;PRINT DATE IN 2 COLS PADDING WITH LEADING BLANK
4502:         MOVEI   TEM,"-"
4503:         XCT     TYO
4504:         POP     P,TAC
4505:         ANDI    TAC,-1          ;CLEAR THE DATE HALF OF TAC
4506:         JRST    PDTIM1          ;PRINT TIME (no use POPing TAC1 and then PUSHing it)
4507: 
4508: DAYT2: PUSH    P,DAT           ; SAVE DAT OVER CALL ON DATIME
4509:         PUSH    P,ITEM          ;AND ITEM               ;JS
4510:         MOVE    TAC,THSDAT      ;PICKUP DATE    ;REG
4511:         PUSHJ   P,DAYCNT        ;CALCULATE
4512:         IDIVI   TAC,7
4513:         LSH     TAC1,1
4514:         MOVEI   TAC,DAYTAB(TAC1)        ;LOAD ADDRESS OF ASCIZ STRING
4515:         PUSHJ   P,CONMES
4516:         PUSHJ   P,PRSPC
4517:         POP     P,ITEM          ;RESTORE STACK 
4518:         POP     P,DAT
4519:         MOVE    TAC,THSDAT      ;END REG STUFF
4520:         IDIVI   TAC,=31
4521:         EXCH    TAC,TAC1        ;YEAR AND MONTH IN TAC1
4522:         AOS     TAC             ;DAY IN TAC
4523:         PUSHJ   P,RADX10        ;PRINT DAY
4524:         MOVEI   TAC,0
4525:         DIVI    TAC,=12
4526:         EXCH    TAC,TAC1
4527:         MOVE    TAC,MONTAB(TAC) ;MONTH
4528:         DPB     TAC,[POINT 21,DAMESS,27]
4529:         MOVEI   TAC,DAMESS
4530:         PUSHJ   P,CONMES        ;PRINT DAY
4531:         MOVEI   TAC,=64(TAC1)
4532:         PUSHJ   P,RADX10        ;PRINT YEAR
4533:         PUSHJ   P,PRSPC         ;ADD SPACES
4534:         HRRZ    TAC,TIMDAT      ;PRINT TIME OF DAY
4535:         PUSHJ   P,PDTIME
4536:         JRST    CRLF
4537: 
4538: DAYTAB:
4539:         ASCIZ/WEDNESDAY/
4540:         ASCIZ/THURSDAY/
4541:         ASCIZ/FRIDAY/
4542:         ASCIZ/SATURDAY/
4543:         ASCIZ/SUNDAY/
4544:         ASCIZ/MONDAY/
4545:         ASCIZ/TUESDAY/
4546: 
4547: MONTHB: 0                       ;JAN
4548:         =31                     ;FEB
4549:         =59                     ;MAR
4550:         =90                     ;APR
4551:         =120                    ;MAY
4552:         =151                    ;JUN
4553:         =181                    ;JUL
4554:         =212                    ;AUG
4555:         =243                    ;SEP
4556:         =273                    ;OCT
4557:         =304                    ;NOV
4558:         =334                    ;DEC
4559: 
4560: ;CALL WITH TAC SET UP W/ SYSTEM FORMAT DATE.
4561: ;RETURN W/ TAC= NUMBER OF DAYS SINCE JAN 1, 1964
4562: ;TAC1 AND AC2 CLOBBERED
4563: DAYCNT:
4564:         IDIVI   TAC,=31         ;DAY OF THE MONTH IN TAC1
4565:         MOVEI   DAT,1(TAC1)     ;DAY INTO DAT
4566:         IDIVI   TAC,=12         ;MONTHS IN TAC1, YEARS IN TAC
4567:         ADD     DAT,MONTHB(TAC1)        ;ADD NUMBER OF DAYS BEFORE THE 1st OF MONTH
4568:         TRNN    TAC,3           ;SKIP UNLESS LEAP YEAR
4569:         CAIGE   TAC1,2          ;LY. SKIP IF AFTER FEBRUARY
4570:         SUBI    DAT,1           ;NOT LEAP YEAR. OR BEFORE MARCH
4571:         MOVEI   TAC1,3(TAC)
4572:         LSH     TAC1,-2         ;NUMBER OF LY SINCE '64 NOT INCLUDING THIS YEAR
4573:         IMULI   TAC,=365        ;NUMBER OF YEARS TIMES 365
4574:         ADDI    TAC,(TAC1)      ;PLUS NUMBER OF PRIOR LEAP YEARS
4575:         ADDI    TAC,(DAT)       ;PLUS NUMBER OF DAYS SO FAR THIS YEAR.
4576:         POPJ    P,
    CLKSER page# 0082 next  prev
4578: ;"TIME (JOB NO.)" - PRINT TOTAL AND INCREMENTAL RUNNING TIME FOR A JOB
4579: ;"TIME 0" IMPLIES RUNTIME FOR NULL JOB AND THE TOTAL TIME SPENT SHUFFLING USERS
4580: ;       IF NO JOB NO. GIVEN-TIME WILL BE FOR CURRENTLY LOGGEN IN JOB NO.
4581: 
4582: RUNTIM: PUSHJ   P,DECIN         ;GET JOB NO. ARG.
4583:         JRST    CRUN1           ;NO ARG. GIVEN
4584:         JRST    COMERA          ;ILLEGAL DECIMAL CHARACTER RETURN
4585:         JUMPE   TAC1,CRUN2      ;RUNTIME 0 GIVEN?
4586:         CAIL    TAC1,JOBN       ;JOB NO. TOO BIG?
4587:         JRST    NOTLOG          ;YES, ILLEGAL JOB NUMBER
4588: CRUN3:  MOVE    TAC,JBTSTS(TAC1);IS THIS A REAL JOB WE HAVE HERE?
4589:         TLNE    TAC,JNA         ;SKIP IF NO NUMBER ASSIGNED.
4590:         TLNE    TAC,JSEG        ;THERE IS A JOB HERE. SKIP IF NOT A SEGMENT
4591:         JRST    NOTLOG          ;NO JOB OR A SEGMENT. PRINT NO SUCH JOB.
4592:         PUSHJ   P,INLMES        ;PRINT TITLES
4593:         ASCIZ   /     TOTAL   INCREMENT        WAIT  KCS
4594: /
4595:         MOVE    TAC,TTIME(TAC1) ;CPU TIME SINCE LAST LOGIN
4596:         PUSHJ   P,PRTIME        ;PRINT COMPUTE TIME USED
4597:         MOVE    TAC,TTIME(TAC1) ;CALCULATE INCREMENTAL RUN TIME
4598:         SUB     TAC,RTIME(TAC1)
4599:         PUSHJ   P,PRTIME        ; AND PRINT IT
4600:         MOVE    TAC,TTIME(TAC1)
4601:         CAMN    J,TAC1          ;PRINTING TIME OUT FOR OWN JOB?
4602:         MOVEM   TAC,RTIME(TAC1) ;YES.  RESET INCREMENTAL TIME.
4603: 
4604:         SKIPGE  TAC,JBTWAT(TAC1);GET TIME WAITING FOR SYSTEM
4605:         ADD     TAC,UPTIME      ;MAKE THIS TIME REAL
4606:         PUSHJ   P,PRTIME        ; AND PRINT IT
4607:         MOVE    TAC,JBTKCJ(TAC1);GET KILO-CORE-JIFFIES USED
4608:         IDIVI   TAC,=60         ; AND CONVERT TO KILO-CORE-SECONDS
4609:         JRST    DECLF           ; AND PRINT IT WITH A CRLF AND RETURN
4610: 
4611: CRUN1:  SKIPE   TAC1,J          ;LOGGED IN?
4612:         JRST    CRUN3           ;YES.  GIVE HIM HIS OWN TIME.
4613: CRUN2:  PUSHJ   P,INLMES        ;"TIME 0" OR UNLOGGED IN "TI"
4614:         ASCIZ   /UP /
4615:         MOVE    TAC,UPTIME
4616:         IDIVI   TAC,=60*=60     ;CONVERT TO MINUTES
4617:         IDIVI   TAC,=60         ;CALCULATE HOURS
4618:         PUSH    P,TAC1          ;SAVE MINUTES
4619:         PUSHJ   P,RADX10        ;PRINT HOURS
4620:         PUSHJ   P,INLMES
4621:         ASCIZ   / hr /
4622:         POP     P,TAC           ;RETRIEVE MINUTES
4623:         PUSHJ   P,RADX10        ;PRINT MINUTES
4624:         PUSHJ   P,INLMES
4625:         ASCIZ   / min;  SHFL /
4626:         MOVE    TAC,SHFWRD      ;NO. WORDS SHUFFLED
4627:         IDIVI   TAC,=1000000/<=60*3>    ;ABOUT THIS MANY WORDS PER TICK.
4628:         PUSHJ   P,PERCNT        ;PRINT AS A PERCENTAGE OF UPTIME
4629:         PUSHJ   P,INLMES
4630:         ASCIZ   /;  NULL /
4631:         MOVE    TAC,TTIME       ;GET NULL TIME
4632:         PUSHJ   P,PERCNT        ;AND PRINT AS A PERCENTAGE OF UPTIME
4633:         PUSHJ   P,INLMES
4634:         ASCIZ   /;  ILEV /
4635:         MOVE    TAC,INTIME
4636:         PUSHJ   P,PERCNT
4637:         PUSHJ   P,INLMES
4638:         ASCIZ   /;  RIT /
4639:         MOVE    TAC,JLRIT
4640:         PUSHJ   P,PERCN1
4641:         JRST    CRLF
4642: 
4643: ;ROUTINE TO PRINT A PERCENTAGE OF UPTIME IN FORM "DD.D%"
4644: ;CALL WITH TIME (IN TICKS) IN TAC: PUSHJ P,PERCNT
4645: 
4646: PERCNT: IMULI   TAC,=1000
4647:         IDIV    TAC,UPTIME
4648: PERCN1: IDIVI   TAC,=10         ;CALCULATE PERCENTAGE
4649:         PUSH    P,TAC1          ;SAVE FRACTION
4650:         PUSHJ   P,RADX10        ;PRINT INTEGRAL PART OF PERCENTAGE
4651:         PUSHJ   P,PRPER         ;PRINT A PERIOD
4652:         POP     P,TEM
4653:         ADDI    TEM,"0"
4654:         XCT     TYO             ;PRINT TENTHS OF A PERCENT
4655:         MOVEI   TEM,"%"
4656:         XCT     TYO             ;PRINT PERCENT SIGN
4657:         POPJ    P,
4658: 
4659: PR2SP:  MOVEI   TEM," "
4660:         XCT     TYO
4661: TYOPOP: XCT     TYO             ;PRINT TWO SPACES AFTER TIME
4662:         POPJ    P,
4663: 
4664: PRCOLN: MOVEI   TEM,":"         ;PRINT COLON
4665:         JRST    TYOPOP
4666: 
4667: ;ROUTINE TO PRINT A TIME IN FORMAT "H:MM:SS'TT  " (HOURS, MINS, SECS, TICKS)
4668: ;CALL WITH TIME IN TICKS IN TAC.  PRESERVES TAC1!
4669: PRTIME: PUSH    P,TAC1
4670:         IDIVI   TAC,=60*=60*=60 ;HOURS INTO TAC
4671:         JUMPE   TAC,PRTIM1      ;PRINT 2 SPACES INSTEAD OF 0: FOR HOURS
4672:         PUSHJ   P,RADX10
4673:         PUSHJ   P,PRCOLN        ;PRINT COLON
4674:         TRCA    TEM,"0"":"     ;MAKE SURE MINUTES GET PADDED WITH 0 IF NECESSARY
4675: PRTIM1: PUSHJ   P,PR2SP         ;PRINT 2 SPACES
4676:         MOVE    TAC,TAC1
4677:         IDIVI   TAC,=60*=60     ;MINUTES INTO TAC
4678:         PUSHJ   P,PRTIM3
4679:         PUSHJ   P,PRCOLN
4680:         MOVE    TAC,TAC1
4681:         IDIVI   TAC,=60         ;SECONDS INTO TAC
4682:         PUSHJ   P,PRTIM2        ;PRINT WITH LEADING 0 IF NECESSARY
4683:         MOVEI   TEM,"'"         ;USE RIGHT QUOTE TO PUNCTUATE TICKS
4684:         XCT     TYO
4685:         MOVE    TAC,TAC1        ;TICKS INTO TAC
4686:         PUSHJ   P,PRTIM2
4687:         PUSHJ   P,PR2SP
4688:         POP     P,TAC1          ;RESTORE TAC1 FROM STACK
4689:         POPJ    P,              ;AND RETURN
4690: 
4691: PRTIM2: MOVEI   TEM,"0"         ;PAD WITH LEADING 0 IF NECESSARY
4692: PRTIM3: CAIGE   TAC,=10         ;ANY PADDING NEEDED?
4693:         XCT     TYO             ;YES.  ONE CHARACTER OF PADDING PLEASE
4694:         JRST    RADX10          ;NOW PRINT TAC AS DECIMAL NUMBER AND RETURN
4695: 
4696: ;ROUTINE TO PRINT TIME OF DAY IN FORMAT "HH:MM  "
4697: ;CALL WITH TIME IN SECONDS IN TAC.  PRESERVES TAC1
4698: PDTIM0: ANDI    TAC,-1          ;CLEAR DATE IN LEFT HALF OF TAC
4699: PDTIME: PUSH    P,TAC1          ;SAVE TAC1
4700: PDTIM1: IDIVI   TAC,=60*=60     ;HOURS INTO TAC
4701:         PUSHJ   P,PRTIM2        ;PRINT HOURS WITH LEADING 0 IF NECESSARY
4702:         PUSHJ   P,PRCOLN
4703:         MOVE    TAC,TAC1
4704:         IDIVI   TAC,=60         ;MINUTES INTO TAC
4705:         PUSHJ   P,PRTIM2        ;PRINT MINUTES WITH LEADING 0 IF NECESSARY
4706:         PUSHJ   P,PR2SP         ;PRINT 2 SPACES
4707:         POP     P,TAC1          ;RESTORE TAC1
4708:         POPJ    P,
    CLKSER page# 0083 next  prev
4710: ;ROUTINE TO LET TTY TALK TO ANY OTHER RING OF TTYS
4711: ;       "TALK TTYN"
4712: ;       TTYN NEED NEVER HAVE BEEN TYPED ON BEFORE
4713: 
4714: TALK:   PUSHJ PDP,CTEXT         ;GET ARGUMENT
4715:         JUMPE TAC1,TALK2        ;NONE SPECIFIED
4716:         MOVE TAC,TAC1
4717:         PUSHJ PDP,DEVSRC        ;SEARCH FOR DEVICE
4718:         JRST TALK1              ;NONE AVAIL
4719:         PUSHJ PDP,TTYTLK
4720:         JRST TALK1
4721:         POPJ PDP,
4722: 
4723: TALK2:
4724:         MOVEM ITEM,-1(PDP)
4725:         JRST NOTENF
4726: 
4727: TALK1:  MOVE DEVDAT,-2(PDP)     ; RESTORE TTY DDB
4728:         MOVSI ITEM,NOINCK       ; SET FLAGS TO PRINT RESPONSE
4729:         MOVEM ITEM,-1(PDP)
4730:         JSP TAC,ERRMES
4731:         ASCIZ /BUSY
4732: /
    CLKSER page# 0084 next  prev
4734: ;"EXAMINE LOC" - LOOKS A CONTENTS OF LOC AND PRINTS IN OCTAL
4735: ;IF LOC IS MISSING, NEXT LOC IS PRINTED
4736: ;TAB. IS PRINTED INSTEAD OF CRLF(LIKE DDT)
4737: 
4738: 
4739: ECOM:   PUSHJ PDP,OCTIN         ;GET OCTAL LOCATION
4740:         JRST ECOM2              ;NO ARG - GET CURRENT LOC
4741:         JRST COMERA             ;ILLEGAL CHARACTER
4742: ECOM1:  PUSHJ P,TESTIN          ;GET SET UP
4743:          JFCL                   ;OK IF WRITE-PROT
4744:         HLRZS TAC               ;GET RELOCATION IN RIGHT HALF OF TAC
4745:         PUSH PDP,TAC            ;PUSH IT
4746:         PUSHJ PDP,DEAT          ;CHECK FOR AC REFERENCE
4747:         SUBI TAC1,(AC3)         ;MAKE REL TO APPROP SEG
4748:         ADDM TAC1,(PDP)         ;RELOCATE ADDR
4749:         HRRZ TAC,JOBEXM(JDAT)   ;PRINT LOC BEING EXAMINED
4750:         PUSHJ PDP,OCTPNT
4751:         PUSHJ PDP,INLMES        ;PRINT SLASH TAB
4752:         ASCIZ %/        %
4753:         HLRZ TAC,@(PDP)         ;PRINT LEFT HALF
4754:         PUSHJ PDP,OCTPNT
4755:         PUSHJ PDP,INLMES        ;PRINT SPACE
4756:         ASCIZ / /
4757:         HRRZ TAC,@(PDP)         ;PRINT RIGHT HALF
4758:         PUSHJ PDP,OCTPNT
4759:         PUSHJ PDP,INLMES        ;PRINT FINAL TAB
4760:         ASCIZ / /
4761:         JRST TPOPJ
4762: 
4763: ;HERE WE GET THE LAST LOC+1. NOTE WE DO NOT CHANGE JOBEXM YET SINCE WE MAY
4764: ;GO TO DLYCOM FROM TESTIN AND DON'T WANT TO AOS IT SEVERAL TIMES.
4765: ECOM2:  MOVE TAC1,JOBEXM(PROG)
4766:         AOJA TAC1,ECOM1
4767: 
4768: ;SETUP ROUTINE FOR EXAMINE/DEPOSIT COMMANDS
4769: ;ADDRESS CHECKS, AND WAITS FOR SWAP (VIA DLYCOM) IF NEEDED FOR UPPER
4770: ;EXECUTES INSTRUCTION FOLLOWING CALL IF WRITE-PROTECTED UPPER
4771: TESTIN: ANDI TAC1,-1            ;FLUSH EXTRANEOUS GARBAGE
4772:         MOVEI AC3,              ;INITIALLY ASSUME LOWER
4773:         MOVS TAC,JBTADR(ITEM)   ;PROT. RELOC.
4774:         CAIG TAC1,(TAC)         ;LEGAL LOC
4775:         JRST CPOPJ1             ;YES, GO ON.
4776:         MOVEI AC3,1(TAC)        ;COMPUTE POSSIBLE UPPER ORIGIN
4777:         LDB AC1,PSEGN           ;# OF UPPER
4778:         JUMPE AC1,ECOMP         ;NONE
4779:         MOVE AC2,JBTSTS(AC1)
4780:         TLNE AC2,JWP            ;IF WRITE-PROTECTED,
4781:         XCT @(P)                ;CHECK LEGALITY BEFORE TRYING TO SWAP
4782:         SKIPE TAC,JBTADR(AC1)   ;PROT. RELOC OF UPPER
4783:         JRST TESTU1
4784:         LDB TAC,IMGIN   ;SWAPPED OUT, GET SIZE
4785:         ASH TAC,12      ;MAKE IT WORDS
4786:         SOJA TAC,.+2    ;MAKE IT HONEST
4787: TESTU1: MOVS TAC,TAC
4788:         CAIGE AC3,400000
4789:         MOVEI AC3,400000        ;AC3 IS NOW ORIGIN OF UPPER
4790:         ADDI TAC,(AC3)          ;RELOCATE PROT TO UPPER
4791:         CAIL TAC1,(AC3)
4792:         CAILE TAC1,(TAC)        ;LEGAL
4793:         JRST ECOMP              ;NO
4794:         TLNN AC2,SWP            ;IS UPPER IN CORE
4795:         JRST CPOPJ1
4796:         MOVSI TAC,JHLDIN
4797:         IORM TAC,JBTSTS(J)      ;KEEP US IN
4798:         EXCH J,AC1
4799:         MOVSI TAC,COMSNB
4800:         PUSHJ P,SETSIN          ;AND GET HIM IN
4801:         MOVE J,AC1
4802:         POP P,(P)
4803:         JRST DLYCM1             ;AND DELAY
4804: 
4805: ECOMP:  POP P,TAC               ;POP OFF RETURN
4806: ECOMA:  JSP TAC,ERRMES          ;ILLEGAL MEMORY REFERENCE
4807: 
4808:         ASCIZ /OUT OF BOUNDS
4809: /
    CLKSER page# 0085 next  prev
4811: ;"DEPOSIT LH RH LOC" - DEPOSITS XWD LH,RH IN LOCATION LOC
4812: ;IF LOC IS MISSING ASSUMB CURRENT LOC
4813: 
4814: 
4815: DCOM:   PUSHJ PDP,OCTIN         ;GET LH
4816:         JRST NOTENF             ;NOT ENOUGH ARGUMENTS
4817:         JRST COMERA             ;ILLEGAL CHARACTER
4818:         HRLM TAC1,IOS           ;SAVE
4819:         PUSHJ PDP,OCTIN         ;GET RH
4820:         JRST NOTENF             ;NOT ENOUGH ARGUMENTS
4821:         JRST COMERA             ;ILLEGAL CHARACTER
4822:         HRRM TAC1,IOS           ;SAVE RH
4823:         PUSHJ PDP,OCTIN         ;GET LOC
4824:         SKIPA TAC1,JOBEXM(JDAT) ;NOT SPECIFIED (DEPOSIT THIS)!
4825:         JRST COMERA             ;ILLEGAL CHARACTER
4826:         PUSHJ P,TESTIN          ;RETURN IF READY FOR DEPOSIT.
4827:          JRST ECOMP             ;LOSE IF WRITE-PROT
4828:         CAIGE TAC1,20           ;IN USER ACS
4829:         JRST .+3
4830:         CAIG TAC1,JOBPFI        ;NO, GREATER THAN HIGHEST LOC. PROTECTED
4831:                                 ;FROM IO IN JOB DATA AREA?
4832:         JRST ECOMA
4833:         HLLM TAC,(PDP)          ;SAVE RELOCATION
4834:         PUSHJ PDP,DEAT          ;CHECK FOR AC REFERENCE
4835:         HLRZ TAC,(PDP)          ;GET RELOCATION
4836:         SUBI TAC1,(AC3)         ;ADJUST ADR FOR POSSIBLE SEGMENT
4837:         ADD TAC1,TAC
4838:         MOVEM IOS,@TAC1
4839: IFN FTSWAP,<
4840:         JUMPE AC3,.+2           ;UPPER?
4841:         SETOM STIME(AC1)        ;YES, MARK IT ALTERED (LOWER WAS GOTTEN BY DEAT)
4842: >
4843:         POPJ PDP,
4844: 
4845: 
4846: 
4847: DEAT:   MOVEM TAC1,JOBEXM(JDAT) ;STORE FOR NEXT TIME
4848: IFN FTSWAP,<
4849:         SETOM STIME(J)          ;AND NOTE THIS CORE IMAGE CHANGED
4850: >       MOVE TAC,JOBPC(JDAT)
4851:         CAMN J,JOB              ;MIGHT BE RUNNING IF HE SAID CCONT ETC.
4852:         MOVE TAC,USRPC
4853:         CAIL TAC1,20            ;IS IT AN AC?
4854:         POPJ PDP,               ;NO
4855:         TLNE TAC,USRMOD         ;USER MODE?
4856:         ADDI TAC1,JOBDAC        ;YES USER ACS ARE HERE
4857:         POPJ PDP,
    CLKSER page# 0086 next  prev
4859: ;"BLANK" OR NO ALPHA NUMERIC BEFORE BREAK CHAR COMMAND
4860: ;DISPATCHED TO LIKE ANY OTHER COMMAND(O IN COMMAND TABLE)
4861: 
4862: 
4863: CBLANK:
4864:         CAIE TEM,12     ; WAS BREAK A L.F.?
4865:         CAIN TEM,";"    ;NO, IS IT SEMI COLON(MONITOR COMMENT)
4866:         POPJ PDP,       ;YES, IGNORE
4867:                         ;FALL IN UNKNOWN COMMAND
4868: 
4869: ;COMMAND NOT IN COMMAND DIRECTORY
4870: 
4871: NOCOM:  JRST COMERR     ;NO, APPEND ? TO WHAT HE TYPED IN
    CLKSER page# 0087 next  prev
4873: ; "FINISH DEVICE" - CLOSES,RELEASE AND DEASSIGNS DEVICE
4874: FINIS:  JUMPE   PROG,CPOPJ      ; NO CORE, NO FINISH!
4875:         PUSHJ   PDP,CTEXT1      ; READ IN THE DEVICE NAME
4876:         MOVEM   TAC1,JOBFDV(JDAT)       ; SAVE THE SIXBIT OF THE DEVICE NAME
4877:         MOVSI   TAC,TTYRNU      ; PUT TTY INTO USER MODE
4878:         IORM    TAC,-1(P)       ; TELL COMRET
4879:         JSP     TAC1,MSTART     ; MAKE US A MONITOR JOB
4880:         JSP     TAC,MONSTR      ; NOW GET SOME ACS AND A PDL
4881:         MOVE    TAC,JOBFDV(JDAT)        ; SET UP TO SEARCH FOR THIS DEVICE
4882:         JUMPE   TAC,FINALL      ; NO DEVICE... FINISH ALL.
4883: FIN3:   PUSHJ   P,DEVLG         ; TRY LOGICAL NAMES FIRST
4884:         JRST    FIN1            ; NOT FOUND, TRY PHYSICAL NAMES
4885:         PUSHJ   P,FINRDV        ; TRY TO FINISH IT
4886:         PUSH    P,[FIN3+1]      ; IF WE RETURN, THAT WASN'T THE RIGHT DEVICE
4887:         JRST    DEV0            ; CONTINUE SCANNING THE DEVICES
4888: 
4889: FIN1:   PUSHJ   P,DEVPHY        ; SEARCH PHYSICAL NAMES
4890:         JRST    FIN2            ; NO NAMES, ERROR
4891:         PUSHJ   P,FINRDV
4892:         PUSH    P,[FIN1+1]
4893:         MOVE    AC1,DEVMOD(DDB)
4894:         TLNN    AC1,DVTTY
4895:         JRST    DEVLP2          ; SEARCH FOR ANOTHER DEVICE OF SAME NAME
4896: 
4897: FIN2:   PUSHJ   P,TTYFNU        ; GET A TTY FOR US
4898:         PUSHJ   P,INLMES        ; GIVE AN ERROR MESSAGE
4899:         ASCIZ /
4900: FINISH WHAT?/
4901:         PUSHJ P,PRCRCC
4902:         JRST    FINXIT          ; LEAVE TTY IN COMMAND MODE,
4903:                                 ; STOP JOB, AND RESCHEDULE
4904: 
4905: 
4906: ; ROUTINE TO FINISH A DEVICE BY RELEASING IT
4907: ; IT FIRST MATCHES IT TO A DEVICE DATA BLOCK IN USRJDA
4908: 
4909: FINRDV: SKIPGE  UCHN,USRHCU(PID)
4910:         JRST    FIN2            ; NO CHANNELS, NO DEVICES
4911:                                 ;BEWARE- YOU'D BETTER BE RUNNING ON P1
4912: FINRD1: HRRZ    AC1,USRJDA(UCHN); GET DDB ADDRESS
4913:         CAME    AC1,DEVDAT      ; IS THIS IT
4914:         SOJGE   UCHN,FINRD1     ; NO, GET ANOTHER
4915:         JUMPL   UCHN,FINSTK     ; IF NOTHING FOUND, CHECK IO PDL
4916:         PUSHJ P,FINREL          ;RELEASE IT
4917: FINRD2: PUSHJ   P,TTYFNU        ; GET A TTY
4918:         PUSHJ   P,PRCRCC
4919: FINXIT: PUSHJ   P,TTYSTC        ; KEEP THE TTY IN COMMAND MODE
4920:         JRST    MSTOP           ; STOP THE JOB NOW
4921: 
4922: FINREL: PUSH P,UCHN
4923:         MOVSI UUO,(<RELEAS>)    ; NOW SET UP TO RELEASE IT
4924:         DPB UCHN,PUUOAC
4925:         MOVE UCHN,DEVMOD(DDB)
4926:         TRNE UCHN,ASSCON        ;WILL DDB BE THERE AFTER RELEASE?
4927:         JRST FINRL1             ;YES
4928:         XCT UUO                 ; RELEASE THE DEVICE
4929: FINRL2: POP P,UCHN
4930:         POPJ P,
4931: 
4932: FINRL1: PUSH P,DDB
4933:         XCT UUO
4934:         POP P,DDB
4935:         MOVSI UCHN,DVDIRIIN     ; CLEAR DIRECTORY IN CORE BIT
4936:         ANDCAM UCHN,DEVMOD(DDB)
4937:         JRST FINRL2
4938: 
4939: FINSTK: MOVE J,JOB(PID)
4940:         SKIPL UCHN,JBTIOP(J)
4941:         POPJ P,                 ;NOTHING ON STACK
4942: FINST1: HRRZ AC1,(UCHN)
4943:         CAME AC1,DDB
4944:         JRST FINST2
4945:         MOVE DDB,USRJDA
4946:         EXCH DDB,(UCHN)
4947:         MOVEM DDB,USRJDA
4948:         PUSH P,UCHN
4949:         MOVEI UCHN,0
4950:         PUSHJ P,FINREL
4951:         POP P,UCHN
4952:         MOVE DDB,(UCHN)
4953:         EXCH DDB,USRJDA
4954:         MOVEM DDB,(UCHN)
4955:         JRST FINRD2
4956: 
4957: FINST2: ADD UCHN,[1,,1]
4958:         AOBJN UCHN,FINST1
4959:         POPJ P,
4960: 
4961: FINALL: SKIPGE  UCHN,USRHCU(PID)        ;SEE IF HE HAS CHANNELS OPEN
4962:         JRST    FINAL3                  ;NONE LEFT OPEN.
4963: FINAL1: SKIPE   DEVDAT,USRJDA(UCHN)     ;IS THERE ANYONE HERE?
4964:         PUSHJ P,FINREL
4965:         SOJGE   UCHN,FINAL1
4966: FINAL3: MOVE    J,JOB(PID)              ;DEPARTMENT OF REDUNDANCY DEPARTMENT
4967:         SKIPL UCHN,JBTIOP(J)            ;ANY IO PDL?
4968:         JRST FINST3
4969: FINST4: SKIPN DDB,(UCHN)
4970:         JRST FINST5
4971:         SETZM (UCHN)
4972:         MOVEM DDB,USRJDA
4973:         PUSH P,UCHN
4974:         SETZ UCHN,
4975:         PUSHJ P,FINREL
4976:         POP P,UCHN
4977: FINST5: ADD UCHN,[1,,1]
4978:         AOBJN UCHN,FINST4
4979:         HRRZ AC1,JBTIOP(J)
4980:         SETZM JBTIOP(J)
4981:         PUSHJ P,FSGIVE
4982: FINST3: PUSHJ   P,FKALL
4983:         JRST    FINRD2
4984: 
4985: ;HERE WE CHASE THROUGH ALL THE DDBS AND MAKE SURE NONE OF THEM BELONG TO THIS JOB
4986: ;FINISH (BY SUPPRESS CLOSE OUTPUT) ANY THAT MAY BE HUNG-OVER
4987: 
4988: FKALL:  MOVEI   DDB,DEVLST-DEVSER
4989: FKALL1: HLRZ    DDB,DEVSER(DDB)
4990:         JUMPE   DDB,CPOPJ
4991:         LDB     AC1,PJOBN
4992:         CAIE    AC1,(J)
4993:         JRST    FKALL1
4994:         MOVE    AC1,DEVMOD(DDB)
4995:         TRNN    AC1,ASSPRG              ;SKIP IF ASSIGNED BY PROGRAM.
4996:         JRST    FKALL1                  ;NO.
4997:         MOVEM   DDB,USRJDA              ;SAVE DDB POINTER. (CHANNEL 0)
4998:         MOVSI   AC1,DVDIRIN
4999:         ANDCAM  AC1,DEVMOD(DDB)
5000:         CLOSE   0,3                     ;CLOSE CHANNEL 0. INHIBIT INPUT/OUTPUT CLOSE
5001:         RELEAS  0,3                     ;RELEASE CHANNEL 0. INHIBIT I/O CLOSE
5002:         JRST    FKALL                   ;START OVER FROM THE FRONT OF DEVICE CHAIN
    CLKSER page# 0088 next  prev
5004: ;"RESOURCES" - PRINT OUT AVAILABLE DEVICES AND FREE BLOCKS ON THE DISK
5005: 
5006: FREDEV:
5007: IFN FTDISK,<                            ;JS
5008:         PUSHJ   P,INLMES
5009:         ASCIZ   /DSK /
5010:         MOVEI AC2,0             ;UNIT 0 IS DSK, NOT UDP
5011: FRUDP1: MOVEI TAC1,(AC2)
5012:         PUSHJ   P,DSKRES        ; GET FREE BLOCK COUNT FROM DISK SERVICE ROUTINE
5013:         PUSHJ   P,RADX10        ;CONVERT TO DECIMAL
5014: 
5015: FRUDP2: ADDI AC2,1              ;NOW DO THE SAME FOR UDPS
5016:         CAILE AC2,UPACKS
5017:         JRST FRUDP9             ;NO MORE UDPS
5018:         PUSHJ P,INLMES
5019:         ASCIZ /
5020: /
5021:         MOVE TAC,DKDBML(AC2)    ;ELSE GET NAME
5022:         MOVE TAC1,DEVNAM(TAC)
5023:         PUSHJ P,PRNAME
5024:         SKIPE TAC,SATADR(AC2)
5025:         PUSHJ P,SATTAC          ;TYPE SATID IF ANY
5026:         MOVEI TAC,[ASCIZ / FREE/]
5027:         SKIPE UDPCNT-1(AC2)
5028:         MOVEI TAC,[ASCIZ / PUBLIC /]
5029:         SKIPL UDPOWN-1(AC2)
5030:         MOVEI TAC,[ASCIZ / PRIVATE /]
5031:         SKIPE UDPOWN-1(AC2)
5032:         JRST FRUDP3
5033:         MOVEI TAC,[ASCIZ / DETACHED FROM SYSTEM/]
5034:         SKIPE UDPCNT-1(AC2)
5035:         MOVEI TAC,[ASCIZ / SWAPPING DEVICE/]
5036: FRUDP3: PUSHJ P,CONMES
5037:         SKIPE SATADR(AC2)
5038:         JRST FRUDP1
5039:         JRST FRUDP2
5040: >
5041: FRUDP9: PUSHJ P,INLMES
5042:         ASCIZ /
5043: DDC /
5044:         MOVE TAC,DDFCNT         ;GET NBR OF DD CHANNELS LEFT
5045:         PUSHJ P,RADX10          ; AND PRINT IT
5046:         PUSHJ P,INLMES
5047:         ASCIZ /
5048: JSA /
5049:         MOVE TAC1,JOBNM1
5050:         SETZ TAC,
5051:         MOVSI AC2,JNA
5052: LOP03:  TDNN AC2,JBTSTS(TAC1)   ;IS THIS JOB SLOT AVAILABLE?
5053:         ADDI TAC,1              ;YES
5054:         SOJG TAC1,LOP03         ;CHECK NEXT SLOT
5055:         PUSHJ P,DECLF           ;PRINT NUMBER OF JOB SLOTS AVAILABLE
5056: 
5057:         PUSH P,[0]
5058:         HLRZ AC1,DEVLST         ;GET DDB POINTER
5059: LOP01:  MOVEI AC2,ASSCON+ASSPRG ;MASK FOR DEVICE ASSIGNED
5060:         TDNN AC2,DEVMOD(AC1)    ;ASSIGNED BY CONSOLE OR PROGRAM?
5061:         PUSHJ PDP,LOP02         ;DEV NOT ASG-CHECK AND PRINT
5062:         HLRZ AC1,DEVSER(AC1)    ;GET NEXT DDB
5063:         JUMPN AC1,LOP01         ;END OF CHAIN?
5064:         PUSHJ P,CRLF            ;YES
5065:         JRST TPOPJ              ;GET THAT EXTRA WORD OFF THE STACK
5066: 
5067: LOP02:  MOVE TAC,DEVMOD(AC1)    ;GET DEVICE CHARACTERISTICS
5068:         TLNE TAC,DVTTY!DVDSK!DVIMP!DVUDP  ;IS IT A TTY OR DSK OR YE OLE IMP?
5069:         POPJ PDP,               ;YES - RETURN
5070: LOP04:  MOVEI TEM,","           ;AND A COMMA
5071:         SKIPE -1(P)
5072:         XCT TYO
5073:         MOVE TAC1,DEVNAM(AC1)   ;NO-SET UP TAC1 AGAIN
5074:         HRRZ AC2,DEVSER(AC1)    ;IS THIS SAME DEVICE AS PREVIOUS ONE?
5075:         CAMN AC2,-1(P)
5076:         HRLZ TAC1,TAC1          ;YES.  DONT PRINT NAME, ONLY NUMBER
5077:         MOVEM AC2,-1(P)         ;AND SAVE FOR NEXT DEVICE
5078:         PUSHJ P,PRNAME          ;GO AND PRINT IT OUT
5079:         POPJ P,
5080: 
5081: SATTAC: PUSH P,TAC              ;SAVE SAT ADDR JUST IN CASE
5082:         MOVEI TEM,"("           ;(SATTAC CALLED BY PJOB FOR UDP)
5083:         XCT TYO
5084:         POP P,TAC
5085:         MOVE TAC1,SATID(TAC)    ;THIS IS VOLUME ID FOR UDPS
5086:         PUSHJ P,PRNAME          ;(IBM VOCABULARY TAKES OVER THE WORLD)
5087:         MOVEI TEM,")"
5088:         XCT TYO
5089:         POPJ P,
    CLKSER page# 0089 next  prev
5091: ;RUNCHK, DLYCOR, DLYCR1
5092: RUNCHK: CAMN ITEM,STUSER        ;SYSTEM TAPE USER?
5093:         JRST DLYCM1             ;YES. DELAY
5094: ACTCHK: JUMPE PROG,ACTCH1       ;DOES JOB HAVE CORE IN MEMORY?
5095:         TLNE AC1,SWP            ;DEC 3.16
5096:         JRST ACTCH1             ;DEC 3.16
5097:         PUSHJ PDP,ANYACT        ;YES, ARE DEVICES ACTIVE?
5098:         JRST DLYCM1             ;YES, DELAY COMMAND.
5099: ACTCH1: MOVE TAC1,-1(PDP)       ;RESTORE COMMAND DISPATCH ADDRESS
5100:         MOVE DDB,-2(PDP)        ;RESTORE TTY DDB ADDRESS
5101:         MOVE AC1,JBTSTS(ITEM)   ;RESTORE JOB STATUS
5102:         POPJ PDP,
5103: 
5104: ;ROUTINE TO DELAY A COMMAND
5105: 
5106: ;DELAYS COMMAND TO BE EXECUTED WHEN JOB IN CORE MEMORY
5107: ;AND POPS LEVEL UP ONE.
5108: 
5109: 
5110: 
5111: DLYCR2: MOVE    TAC1,LINSAV     ;GET THE LINE NUMBER
5112:         MOVSI   TAC,COMBIT
5113:         CONO    PI,SCNOFF
5114:         TDNE    TAC,TTYTAB(TAC1)
5115:         SOS     COMCNT          ;DECREMENT IF COMMAND BIT WAS SET
5116:         ANDCAM  TAC,TTYTAB(TAC1)
5117: IFN FTTTYBUG,<
5118:         PUSHJ   P,COMBCK
5119:         PUSHJ   P,CNTCOM
5120: >
5121:         CONO    PI,SCNON
5122:         POPJ    P,
5123: 
5124: DLYCR1: PUSHJ   P,DLYCR2        ;CLEAR COMBIT
5125:         JRST    DLYCM1          ;
5126: 
5127: DLYCOR: PUSHJ   P,DLYCR2        ;CLEAR COMBIT
5128: DLYCM:  PUSHJ   PDP,DLYCOM      ;REQUEUE JOB TO CMWQ 
5129: DLYCM1:AOS     NDLYCMS         ;COUNT A DELAYED COMMAND
5130:         POP     P,TAC           ;FLUSH THE RETURN TO COMRET
5131:         POP     P,TAC1          ;AND FLUSH THE COMMAND BITS
5132:         POP     P,TAC1          ;AND FLUSH THE TTY DDB POINTER.
5133:         PUSHJ   P,TTYCM         ;DELAY PRESENT COMMAND AND GET A NEW COMMAND
5134:         POPJ    P,              ;THERE ARE NO NEW COMMANDS
5135:         JRST    COM0            ;PROCESS A COMMAND.
    CLKSER page# 0090 next  prev
5137: ;SEARCH DEVICE CHAIN FOR DSK WITH COUNTS ON
5138: ;CALL   MOVE ITEM,JOB NO
5139: ;       PUSHJ PDP,STOPCK
5140: ;       CAN'T STOP RETURN
5141: ;       OK TO STOP RETURN
5142: 
5143: IFN FTDISK,<
5144: 
5145: STOPCK:PUSH PDP,DEVDAT
5146:         MOVEI DEVDAT,DSKDDB
5147:         MOVSI TAC1,DSKFGS
5148: STOPD:  LDB TAC,PJOBN
5149:         CAIE ITEM,(TAC)         ;ASSIGNED TO THIS JOB?
5150:         JRST STOPC              ;NO
5151:         TDNE TAC1,DEVIOS(DEVDAT)        ;DUMP MODE I/O IN PROGRESS ?
5152:         JRST STOPR1             ;YES. DELAY
5153: STOPC:  HLRZ DEVDAT,DEVSER(DEVDAT)
5154:         MOVE TAC,DEVMOD(DDB)    ;LOOP THRU DSK AND UDP DDBS
5155:         TLNE TAC,DVDSK
5156:         JRST STOPD              ;ONLY LOOK AT DVDSK ONES
5157:         TLNE TAC,DVUDP
5158:         JRST STOPC              ;BUT KEEP SEARCHING IF DVUDP
5159:         AOS -1(PDP)             ;OK TO STOP
5160: STOPR1: POP PDP,DEVDAT
5161:         POPJ PDP,
5162: >
    CLKSER page# 0091 next  prev
5164: ;"FILES <filename or job number>" -- print status of open files.
5165: 
5166: FILCOM: MOVEI   AC1,DSKDDB
5167:         PUSHJ   P,CTEXT1        ;GET ARG OF COMMAND
5168:         JUMPE   TAC1,FIL2       ;NO ARG
5169:         PUSH    P,TAC1          ;SAVE ARG
5170:         CAIN    TEM,"."         ;DELIMITING PERIOD MEANS FILENAME EXT COMING
5171:         JRST    FIL3            ;READ EXT
5172:         CAIN    TEM,"["         ;DELIMITING LEFT BRACKET MEANS PPN COMING
5173:         JRST    FIL4            ;READ PPN
5174:         PUSHJ   P,FIL2JB        ;SEE IF ARG WAS A JOB NUMBER RATHER THAN FILENAME
5175:         JRST    FIL5            ;GOT JOB NUMBER
5176:         PUSH    P,[0]           ;MUST BE FILE NAME WITH ZERO EXTENSION.
5177: FIL6D:  SKIPN   AC2,DSKPPN(J)   ;GET APPROPRIATE PPN FOR FILE
5178:         MOVE    AC2,PRJPRG(J)
5179: FIL6:   PUSH    P,AC2           ;SAVE PPN
5180:         PUSHJ   P,FIL99         ;SEE IF ANYTHING LEFT IN COMMAND LINE
5181:         PUSHJ   P,CRLF          ;BLANK LINE TO INDICATE STARTING NEW FILE SEARCH
5182: FIL6A:  PUSHJ   P,NXTDSK        ;GET NEXT DSK DDB
5183:         JRST    FIL6B           ;NONE, DONE
5184:         MOVE    TAC,DEVFIL(AC1) ;GET NAME OF FILE OPEN
5185:         CAME    TAC,-2(P)       ;SAME AS FILE OF INTEREST?
5186:         JRST    FIL6A           ;NOPE
5187:         HLLZ    TAC,DEVEXT(AC1) ;GET EXT OF FILE OPEN
5188:         CAME    TAC,-1(P)       ;SAME AS FILE OF INTEREST?
5189:         JRST    FIL6A           ;NOPE
5190:         MOVE    TAC,FILPPN(AC1) ;AND PPN
5191:         CAMN    TAC,(P)         ;SAME?
5192: FIL6C:  PUSHJ   P,PTFILE        ;YES.  PRINT STATUS OF THIS FILE
5193:         JRST    FIL6A           ;NOT SAME, OR STATUS PRINTED OK.
5194:         HRRZM   AC1,SAVDDB(DDB) ;NO ROOM TO PRINT FILE NAME.  SAVE OUR PLACE.
5195:         JRST    .+2
5196: FIL6B:  SETZM   SAVDDB(DDB)     ;WE FINISHED.  INDICATE NO PLACE TO CONTINUE.
5197:         SUB     P,[3,,3]        ;RE-ADJUST STACK, FLUSHING FILE NAME, EXT, PPN
5198:         POPJ    P,
5199: 
5200: FIL4:   SKIPA   TAC1,[0]        ;ZERO FILE EXTENSION
5201: FIL3:   PUSHJ   P,CTEXT         ;READ FILE EXTENSION
5202:         PUSH    P,TAC1          ;SAVE EXT
5203: FIL3A:  PUSHJ   P,PJPGNO        ;READ PPN
5204:         JRST    FIL6D           ;NONE TYPED, GET DEFAULT PPN
5205:         JRST    FIL6            ;GO SAVE PPN TYPED
5206: 
5207: FIL99:  PUSHJ   P,SKIPS1        ;SEE IF ANYTHING EXTRANEOUS AT END OF LINE
5208:         SUB     P,[4,,4]        ;YES.  ERROR
5209:         JRST    COMERA          ;(SKIPS1 RETURNS UP A LEVEL IF FINDS END OF LINE)
5210: 
5211: FIL88:  PUSHJ   P,SKIPS1        ;COMEND MAKES THIS CHECK ALSO BUT ONLY REMOVES
5212:         SUB     P,[2,,2]        ;       ONE ENTRY FROM STACK INSTEAD OF TWO
5213:         JRST    COMERA
5214: 
5215: FIL5:   SUB     P,[1,,1]        ;DISCARD SIXBIT JOB NUMBER ON STACK
5216:         JUMPN   TAC,FIL5D       ;ZERO JOB NUMBER MEANS OWN JOB,
5217: FIL5C:  SKIPN   TAC,J           ; IF ANY.
5218:         JRST    LOGPLS          ; IF NONE, CANT HELP YOU
5219: FIL5D:  MOVE    TAC1,JBTSTS(TAC);SEE IF THIS JOB NUMBER IS ASSIGNED
5220:         TLNE    TAC1,JNA
5221:         TLNE    TAC1,JSEG       ;NO SEGMENTS PLEASE
5222:         JRST    NOTLOG          ;NO SUCH JOB
5223:         PUSH    P,TAC           ;SAVE JOB NUMBER
5224:         PUSHJ   P,FIL88         ;MAKE SURE NOTHING EXTRANEOUS AFTER JOB NUMBER
5225:         PUSHJ   P,CRLF          ;BEGINNING NEW FILE SEARCH
5226: FIL5A:  PUSHJ   P,NXTDSK        ;GET NEXT DSK DDB
5227:         JRST    FIL5B           ;NONE, DONE
5228:         LDB     TAC1,[POINT 6,DEVCHR(AC1),5] ;PICK UP JOB NUMBER FROM DDB
5229:         CAMN    TAC1,(P)        ;IS IT THE JOB OF INTEREST?
5230: FIL5E:  PUSHJ   P,PTFILE        ;YUP.  PRINT FILE STATUS
5231:         JRST    FIL5A           ;NOT CORRECT JOB, OR FILE STATUS PRINTED OK
5232:         HRL     AC1,(P)         ;NO ROOM TO PRINT FILE STATUS.  SAVE JOB NUMBER
5233:         MOVEM   AC1,SAVDDB(DDB) ; AND CURRENT DSK DDB.
5234:         JRST    TPOPJ           ;RE-ADJUST STACK AND RETURN.
5235: FIL5B:  SETZM   SAVDDB(DDB)     ;WE FINISHED.  INDICATE NO PLACE TO CONTINUE.
5236:         JRST    TPOPJ
5237: 
5238: FIL2JB: TDNE    TAC1,[77,,-1]   ;CONVERT SIXBIT TEXT TO JOB NUMBER
5239:         JRST    CPOPJ1          ;MORE THAN TWO CHARS MEANS NOT JOB NUMBER
5240:         SETZ    TAC,
5241:         LSHC    TAC,6           ;GET FIRST SIXBIT CHAR
5242:         SUBI    TAC,'0'         ;CONVERT DIGIT TO BINARY
5243:         JUMPL   TAC,CPOPJ1      ;NOT DIGIT MEANS NOT JOB NUMBER
5244:         CAILE   TAC,=9
5245:         JRST    CPOPJ1          ;NOT DIGIT
5246:         JUMPE   TAC1,CPOPJ      ;IF NO SECOND DIGIT, THEN DONE
5247:         ROT     TAC1,6          ;GET SECOND DIGIT
5248:         SUBI    TAC1,'0'        ;CONVERT SIXBIT DIGIT TO BINARY
5249:         JUMPL   TAC1,CPOPJ1     ;NO DIGEE, NO JOBEE
5250:         CAILE   TAC1,=9
5251:         JRST    CPOPJ1          ;LOSE
5252:         IMULI   TAC,=10         ;SHIFT HIGH-ORDER DIGIT
5253:         ADD     TAC,TAC1        ; AND ADD IN LOW-ORDER DIGIT
5254:         POPJ    P,              ;DIRECT RETURN WITH JOB NUMBER IN TAC
5255: 
5256: FIL2:   PUSHJ   P,COMEND        ;MAKE SURE REALLY NO ARG
5257:         HRRZ    TAC,SAVDDB(DDB) ;NO ARGUMENT.  GET PLACE WE QUIT LAST TIME.
5258:         JUMPE   TAC,FIL5C       ;FINISHED LAST TIME.  START OVER.
5259: FIL2A:  PUSHJ   P,NXTDSK        ;GET NEXT DSK DDB
5260:         JRST    FIL5C           ;NO MORE.  CANT FIND PLACE TO CONTINUE.  START OVER.
5261:         CAME    TAC,AC1         ;IS THIS THE DDB WHERE WE QUIT?
5262:         JRST    FIL2A           ;NO, TRY AGAIN.
5263:         HLRZ    TAC,SAVDDB(DDB) ;YES.  PICK UP JOB NUMBER WE WERE WORKING ON
5264:         PUSH    P,TAC           ;PUT JOB NUMBER ON STACK
5265:         JUMPN   TAC,FIL5E       ; AND CONTINUE PRINTING FILES FOR THAT JOB.
5266:         MOVE    TAC,DEVFIL(AC1) ;NO JOB NUMBER.  MUST BE WORKING ON SPECIFIC FILE.
5267:         MOVEM   TAC,(P)
5268:         PUSH    P,DEVEXT(AC1)   ; SAVE NAME, EXT, AND PPN OF FILE
5269:         HLLZS   (P)             ; CLEAR RIGHT HALF OF EXT WORD
5270:         PUSH    P,FILPPN(AC1)
5271:         JRST    FIL6C           ;AND CONTINUE PRINTING REFERENCES TO THAT FILE
5272: 
5273: PTFILE: MOVEI   TAC,=39+4       ;PRINT A FILE'S STATUS, AT MOST =39 CHARS NEEDED.
5274:         CAML    TAC,TOFCTR(DDB) ;SEE IF WE HAVE ENOUGH ROOM IN OUTPUT BUFFER
5275:         JRST    PTFIL1          ;NOT ENOUGH ROOM.  PRINT " ..." (4 CHARS)
5276:         LDB     TAC,[POINT 6,DEVCHR(AC1),5] ; GET NUMBER OF JOB WITH FILE OPEN
5277:         MOVEI   TEM," "
5278:         CAIGE   TAC,=10         ;IF JOB NUMBER LESS THAN =10,
5279:         XCT     TYO             ; THEN PAD NUMBER WITH A SPACE
5280:         PUSHJ   P,RADX10        ;PRINT JOB NUMBER
5281:         MOVE    TAC1,DEVFIL(AC1);GET FILE NAME
5282:         PUSHJ   P,PR6SIX        ; AND PRINT 6 CHARS AFTER SPACE
5283:         HLLZ    TAC1,DEVEXT(AC1);GET FILE EXT
5284:         PUSHJ   P,PR3SIX        ; AND PRINT 3 CHARS AFTER SPACE
5285:         MOVE    TAC1,FILPPN(AC1);GET FILE PPN
5286:         PUSHJ   P,PR6SIX        ; AND PRINT 6 CHARS AFTER SPACE
5287:         MOVE    TAC,FILLNG(AC1) ;GET FILE LENGTH
5288:         PUSHJ   P,DGETL1        ; AND CONVERT TO RECORDS (DGETL1 IS IN DSKSER)
5289:         SKIPE   TAC1,TAC        ;IF NON-ZERO, SUBTRACT ONE TO GET NUMBER
5290:         SUBI    TAC1,1          ; OF LAST RECORD, NOT FIRST FREE RECORD
5291:         PUSHJ   P,PRREC         ; PRINT FILE LENGTH IN RECORDS
5292:         MOVE    TAC1,USETP(AC1) ;GET CURRENT USET POINTER
5293:         PUSHJ   P,PRREC         ; AND PRINT IT
5294:         MOVEI   TEM," "
5295:         XCT     TYO             ;PRINT A SPACE
5296:         MOVEI   TEM,"U"
5297:         TLNE    AC2,DVUDP       ;IS THIS A UDP?
5298:         XCT     TYO             ;YES, PRINT "U"
5299:         MOVE    TAC,DEVIOS(AC1) ;SEE WHAT IS HAPPENING TO THIS FILE
5300:         TLNN    TAC,READB       ;BEING READ?
5301:         JRST    PTFIL2          ;NO
5302:         MOVEI   TEM,"R"         ;YES.  PRINT "R"
5303:         XCT     TYO
5304:         MOVEI   TEM,"A"
5305:         TLNE    TAC,ALTERB      ;OPEN IN READ-ALTER MODE?
5306:         XCT     TYO             ;YUP,  PRINT "A" AFTER THE "R"
5307:         MOVEI   TEM,"E"
5308:         TLNE    TAC,IOEND       ;END OF FILE?
5309:         XCT     TYO             ;YES, PRINT "E"
5310:         JRST    CRLF            ;PRINT CRLF AND RETURN FROM PTFILE
5311: PTFIL2: MOVEI   TEM,"W"
5312:         TLNE    TAC,WRITEB      ;IS FILE BEING WRITTEN?
5313:         XCT     TYO             ;YES, PRINT "W"
5314:         JRST    CRLF            ;PRINT CRLF AND RETURN FROM PTFILE
5315: 
5316: PTFIL1: PUSHJ   P,INLMES
5317:         ASCIZ   / .../
5318:         JRST    CPOPJ1
5319: 
5320: PR3SIX: MOVEI   UCHN,3          ;PRINT 3 SIXBIT CHARS
5321:         JRST    .+2
5322: PR6SIX: MOVEI   UCHN,6          ;PRINT 6 SIXBIT CHARS
5323:         MOVEI   TEM," "
5324:         XCT     TYO
5325: PRSIXA: SETZ    TAC,
5326:         LSHC    TAC,6           ;GET NEXT SIXBIT CHAR
5327:         MOVEI   TEM,40(TAC)     ;PRINT ASCII
5328:         XCT     TYO
5329:         SOJG    UCHN,PRSIXA     ;PRINTED ENOUGH CHARS YET?
5330:         POPJ    P,              ;YUP
5331: 
5332: PRREC:  MOVEI   UCHN,5          ;PRINT OCTAL NUMBER IN 6 CHARS WITH LEADING BLANKS
5333:         MOVEI   TEM," "
5334:         HRLZ    TAC1,TAC1       ;PUT OCTAL NUMBER IN LEFT HALF OF TAC1
5335: PRREC2: SETZ    TAC,
5336:         LSHC    TAC,3           ;GET NEXT OCTAL DIGIT
5337:         JUMPN   TAC,PRREC1      ;IF NON ZERO, GO PRINT
5338:         XCT     TYO             ;OTHERWISE, PRINT SPACE
5339:         SOJG    UCHN,PRREC2     ;PRINTED 5 LEADING SPACES YET?
5340: PRREC3: SETZ    TAC,
5341:         LSHC    TAC,3           ;GET NEXT OCTAL DIGIT
5342: PRREC1: MOVEI   TEM,"0"(TAC)    ;PRINT ASCII DIGIT
5343:         XCT     TYO
5344:         SOJGE   UCHN,PRREC3     ;PRINTED 6 CHARS YET?
5345:         POPJ    P,              ;YES.  DONE AT LAST
5346: 
5347: NXTDSK: HLRZ    AC1,DEVSER(AC1) ;GET LINK TO NEXT DDB
5348:         JUMPE   AC1,CPOPJ       ;DIRECT RETURN IF NONE
5349:         MOVE    AC2,DEVMOD(AC1) ;GET DEVICE CHARACTERISTICS
5350:         TLNN    AC2,DVDSK       ;IS THIS A DSK DDB?
5351:         JRST    NXTDSK          ;NO.  GET NEXT DDB
5352:         JRST    CPOPJ1          ;YES.  SKIP RETURN WITH DSK DDB
 EOF: CLKSER end-of-file. cnt=90